Esempio n. 1
0
        private void DrawEffectsGUI()
        {
            if (PCommon.CurrentRenderPipeline == PRenderPipelineType.Universal)
            {
                return;
            }
            PWaterFX fx = water.GetComponent <PWaterFX>();

            if (fx != null)
            {
                return;
            }

            string label = "Effects";
            string id    = "effects" + water.GetInstanceID();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                bool isStackV2Installed = false;
#if UNITY_POST_PROCESSING_STACK_V2
                isStackV2Installed = true;
#endif
                if (!isStackV2Installed)
                {
                    EditorGUILayout.LabelField("Water effect need the Post Processing Stack V2 to work. Please install it using the Package Manager", PEditorCommon.WordWrapItalicLabel);
                }
                GUI.enabled = isStackV2Installed;
                if (GUILayout.Button("Add Effects"))
                {
                    fx       = water.gameObject.AddComponent <PWaterFX>();
                    fx.Water = water;
                }
                GUI.enabled = true;
            });
        }
Esempio n. 2
0
        private void DrawSelectedSegmentGUI()
        {
            int segmentIndex = splineEditingGUIDrawer.selectedSegmentIndex;

            if (segmentIndex < 0 ||
                segmentIndex >= water.Spline.Anchors.Count)
            {
                return;
            }
            string label = "Selected Segment";
            string id    = "poseidon-selected-segment";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                EditorGUI.BeginChangeCheck();
                PSplineSegment s                    = water.Spline.Segments[segmentIndex];
                GUI.enabled                         = !PSplineToolConfig.Instance.AutoTangent;
                s.StartTangent                      = PEditorCommon.InlineVector3Field("Start Tangent", s.StartTangent);
                s.EndTangent                        = PEditorCommon.InlineVector3Field("End Tangent", s.EndTangent);
                GUI.enabled                         = true;
                s.ResolutionMultiplierY             = EditorGUILayout.Slider("Resolution Multiplier Y", s.ResolutionMultiplierY, 0f, 2f);
                water.Spline.Segments[segmentIndex] = s;
                if (EditorGUI.EndChangeCheck())
                {
                    water.GenerateSplineMeshAtSegment(segmentIndex);
                }
                EditorGUI.indentLevel += 1;
            });
        }
Esempio n. 3
0
        private void DrawMeshSettingsGUI()
        {
            string      label = "Mesh";
            string      id    = "water-profile-mesh";
            GenericMenu menu  = new GenericMenu();

            menu.AddItem(
                new GUIContent("Generate"),
                false,
                () => { water.GenerateMesh(); });

            PEditorCommon.Foldout(label, true, id, () =>
            {
                if (water.MeshType == PWaterMeshType.TileablePlane)
                {
                    DrawTilableMeshGUI();
                }
                else if (water.MeshType == PWaterMeshType.Area)
                {
                    DrawAreaMeshGUI();
                }
                else if (water.MeshType == PWaterMeshType.Spline)
                {
                    DrawSplineMeshGUI();
                }
                else if (water.MeshType == PWaterMeshType.CustomMesh)
                {
                    DrawCustomMeshGUI();
                }
            }, menu);
        }
Esempio n. 4
0
        private void DrawCausticSettings()
        {
            string label = "Caustic";
            string id    = "water-profile-caustic";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                bool valid = profile.EnableLightAbsorption && (profile.EnableRefraction || water.MeshType == PWaterMeshType.Spline);
                if (!valid)
                {
                    EditorGUILayout.LabelField("Requires Light Absorbtion and Refraction.", PEditorCommon.WordWrapItalicLabel);
                    profile.EnableCaustic = false;
                }

                GUI.enabled           = valid;
                profile.EnableCaustic = EditorGUILayout.Toggle("Enable", profile.EnableCaustic);
                if (profile.EnableCaustic)
                {
                    profile.CausticTexture            = PEditorCommon.InlineTextureField("Texture", profile.CausticTexture, -1);
                    profile.CausticSize               = EditorGUILayout.FloatField("Size", profile.CausticSize);
                    profile.CausticStrength           = EditorGUILayout.Slider("Strength", profile.CausticStrength, 0f, 5f);
                    profile.CausticDistortionStrength = EditorGUILayout.FloatField("Distortion", profile.CausticDistortionStrength);
                }
                GUI.enabled = true;
            });
        }
Esempio n. 5
0
        public void DrawDebugGUI()
        {
            string label = "Debug";
            string id    = "debug" + water.GetInstanceID().ToString();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                Camera[] cams = water.GetComponentsInChildren <Camera>();
                for (int i = 0; i < cams.Length; ++i)
                {
                    if (!cams[i].name.StartsWith("~"))
                    {
                        continue;
                    }
                    if (cams[i].targetTexture == null)
                    {
                        continue;
                    }
                    EditorGUILayout.LabelField(cams[i].name);
                    Rect r = GUILayoutUtility.GetAspectRect(1);
                    EditorGUI.DrawPreviewTexture(r, cams[i].targetTexture);
                    EditorGUILayout.Space();
                }
            });
        }
Esempio n. 6
0
        private void DrawVolumesGUI()
        {
            string label = "Volumes";
            string id    = "volumes" + instance.GetInstanceID();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                instance.VolumeExtent = PEditorCommon.InlineVector3Field("Extent", instance.VolumeExtent);
                instance.VolumeLayer  = EditorGUILayout.LayerField("Layer", instance.VolumeLayer);
            });
        }
Esempio n. 7
0
        private void DrawFresnelSettingsGUI()
        {
            string label = "Fresnel";
            string id    = "water-profile-fresnel";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                profile.FresnelStrength = EditorGUILayout.Slider("Strength", profile.FresnelStrength, 0f, 10f);
                profile.FresnelBias     = EditorGUILayout.Slider("Bias", profile.FresnelBias, 0f, 1f);
            });
        }
Esempio n. 8
0
        private void DrawLightAbsorbtionSettingsGUI()
        {
            string label = "Light Absorption";
            string id    = "water-profile-absorption";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                profile.EnableLightAbsorption = EditorGUILayout.Toggle("Enable", profile.EnableLightAbsorption);
                if (profile.EnableLightAbsorption)
                {
                    profile.DepthColor = EditorGUILayout.ColorField("Depth Color", profile.DepthColor);
                    profile.MaxDepth   = EditorGUILayout.FloatField("Max Depth", profile.MaxDepth);
                }
            });
        }
Esempio n. 9
0
        private void DrawRippleSettingsGUI()
        {
            string label = "Ripple";
            string id    = "water-profile-ripple";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                //instance.EnableRipple = EditorGUILayout.Toggle("Enable", instance.EnableRipple);
                if (profile.EnableRipple)
                {
                    profile.RippleHeight     = EditorGUILayout.Slider("Height", profile.RippleHeight, 0f, 1f);
                    profile.RippleNoiseScale = EditorGUILayout.FloatField("Scale", profile.RippleNoiseScale);
                    profile.RippleSpeed      = EditorGUILayout.FloatField("Speed", profile.RippleSpeed);
                }
            });
        }
Esempio n. 10
0
        private void DrawRefractionSettings()
        {
            string label = "Refraction";
            string id    = "water-profile-refraction";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                if (water.MeshType != PWaterMeshType.Spline)
                {
                    profile.EnableRefraction = EditorGUILayout.Toggle("Enable", profile.EnableRefraction);
                }
                if (profile.EnableRefraction || water.MeshType == PWaterMeshType.Spline)
                {
                    profile.RefractionDistortionStrength = EditorGUILayout.FloatField("Distortion", profile.RefractionDistortionStrength);
                }
            });
        }
        private void DrawWetLensGUI()
        {
            string label = "Wet Lens";
            string id    = "wet-lens" + instance.GetInstanceID();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                instance.EnableWetLens = EditorGUILayout.Toggle("Enable", instance.EnableWetLens);
                if (instance.EnableWetLens)
                {
                    instance.WetLensNormalMap = PEditorCommon.InlineTextureField("Normal Map", instance.WetLensNormalMap, -1);
                    instance.WetLensStrength  = EditorGUILayout.Slider("Strength", instance.WetLensStrength, 0f, 1f);
                    instance.WetLensDuration  = EditorGUILayout.FloatField("Duration", instance.WetLensDuration);
                    instance.WetLensFadeCurve = EditorGUILayout.CurveField("Fade", instance.WetLensFadeCurve, Color.red, new Rect(0, 0, 1, 1));
                }
            });
        }
Esempio n. 12
0
        private void DrawWaveSettingsGUI()
        {
            string label = "Wave";
            string id    = "water-profile-ripple";

            PEditorCommon.Foldout(label, false, id, () =>
            {
                profile.EnableWave = EditorGUILayout.Toggle("Enable", profile.EnableWave);
                if (profile.EnableWave)
                {
                    profile.WaveDirection = EditorGUILayout.Slider("Direction", profile.WaveDirection, 0f, 360f);
                    profile.WaveSpeed     = EditorGUILayout.FloatField("Speed", profile.WaveSpeed);
                    profile.WaveHeight    = EditorGUILayout.FloatField("Height", profile.WaveHeight);
                    profile.WaveLength    = EditorGUILayout.FloatField("Length", profile.WaveLength);
                    profile.WaveSteepness = EditorGUILayout.Slider("Steepness", profile.WaveSteepness, 0f, 1f);
                    profile.WaveDeform    = EditorGUILayout.Slider("Deform", profile.WaveDeform, 0f, 1f);
                }
            });
        }
Esempio n. 13
0
        private void DrawRenderingSettingsGUI()
        {
            string label = "Rendering";
            string id    = "water-profile-general";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                GUI.enabled = false;
                EditorGUILayout.ObjectField("Material", water.MaterialToRender, typeof(Material), false);
                if (water.MeshType == PWaterMeshType.TileablePlane && water.ShouldRenderBackface)
                {
                    EditorGUILayout.ObjectField("Material Back Face", water.MaterialBackFace, typeof(Material), false);
                }
                GUI.enabled = true;

                if (PCommon.CurrentRenderPipeline == PRenderPipelineType.Builtin)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Light Model");
                    Rect r = EditorGUILayout.GetControlRect();
                    if (GUI.Button(r, "Physical Based", EditorStyles.popup))
                    {
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Physical Based"), false, () => { });
                        menu.AddDisabledItem(new GUIContent("Blinn Phong (SRP)"));
                        menu.AddDisabledItem(new GUIContent("Lambert (SRP)"));
                        menu.DropDown(r);
                    }
                    EditorGUILayout.EndHorizontal();
                    profile.LightingModel = PLightingModel.PhysicalBased;
                }
                else
                {
                    profile.LightingModel = (PLightingModel)EditorGUILayout.EnumPopup("Light Model", profile.LightingModel);
                }

                profile.RenderQueueIndex = EditorGUILayout.IntField("Queue Index", profile.RenderQueueIndex);
                if (water.MeshType == PWaterMeshType.TileablePlane)
                {
                    water.ShouldRenderBackface = EditorGUILayout.Toggle("Render Back Face", water.ShouldRenderBackface);
                }
            });
        }
Esempio n. 14
0
        private void DrawColorsSettingsGUI()
        {
            string label = "Colors";
            string id    = "water-profile-colors";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                profile.Color = EditorGUILayout.ColorField("Color", profile.Color);
                if (profile.EnableLightAbsorption)
                {
                    profile.DepthColor = EditorGUILayout.ColorField("Depth Color", profile.DepthColor);
                }
                if (profile.LightingModel == PLightingModel.PhysicalBased || profile.LightingModel == PLightingModel.BlinnPhong)
                {
                    //instance.SpecColor = EditorGUILayout.ColorField("Specular Color", instance.SpecColor);
                    profile.SpecColor  = EditorGUILayout.ColorField(new GUIContent("Specular Color"), profile.SpecColor, true, false, true);
                    profile.Smoothness = EditorGUILayout.Slider("Smoothness", profile.Smoothness, 0f, 1f);
                }
            });
        }
Esempio n. 15
0
        private void DrawReflectionSettings()
        {
            if (water.MeshType == PWaterMeshType.Spline)
            {
                return;
            }

            bool stereoEnable = false;

            if (Camera.main != null)
            {
                stereoEnable = Camera.main.stereoEnabled;
            }

            string label = "Reflection" + (stereoEnable ? " (Not support for VR)" : "");
            string id    = "water-profile-reflection";

            GUI.enabled = !stereoEnable;
            PEditorCommon.Foldout(label, true, id, () =>
            {
                profile.EnableReflection = EditorGUILayout.Toggle("Enable", profile.EnableReflection);
                if (profile.EnableReflection)
                {
                    profile.ReflectCustomSkybox        = EditorGUILayout.Toggle("Custom Skybox", profile.ReflectCustomSkybox);
                    profile.EnableReflectionPixelLight = EditorGUILayout.Toggle("Pixel Light", profile.EnableReflectionPixelLight);
                    profile.ReflectionClipPlaneOffset  = EditorGUILayout.FloatField("Clip Plane Offset", profile.ReflectionClipPlaneOffset);

                    if (reflectionLayersSO != null)
                    {
                        EditorGUILayout.PropertyField(reflectionLayersSO);
                    }
                    so.ApplyModifiedProperties();

                    profile.ReflectionTextureResolution  = EditorGUILayout.IntPopup("Resolution", profile.ReflectionTextureResolution, renderTextureSizeLabels, renderTextureSizes);
                    profile.ReflectionDistortionStrength = EditorGUILayout.FloatField("Distortion", profile.ReflectionDistortionStrength);
                }
            });
            GUI.enabled = true;
        }
Esempio n. 16
0
        private void DrawFoamSettingsGUI()
        {
            string label = "Foam";
            string id    = "water-profile-foam";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                profile.EnableFoam = EditorGUILayout.Toggle("Enable", profile.EnableFoam);
                if (profile.EnableFoam)
                {
                    profile.EnableFoamHQ = EditorGUILayout.Toggle("High Quality", profile.EnableFoamHQ);
                    if (profile.EnableFoamHQ)
                    {
                        profile.FoamNoiseScaleHQ = EditorGUILayout.FloatField("Scale", profile.FoamNoiseScaleHQ);
                        profile.FoamNoiseSpeedHQ = EditorGUILayout.FloatField("Speed", profile.FoamNoiseSpeedHQ);
                    }
                    profile.FoamColor = EditorGUILayout.ColorField(new GUIContent("Color"), profile.FoamColor, true, true, true);

                    PEditorCommon.Header("Shoreline");
                    profile.FoamDistance          = EditorGUILayout.FloatField("Distance", profile.FoamDistance);
                    profile.ShorelineFoamStrength = EditorGUILayout.Slider("Strength", profile.ShorelineFoamStrength, 0f, 1f);

                    if (profile.EnableWave)
                    {
                        PEditorCommon.Header("Crest");
                        profile.CrestMaxDepth     = EditorGUILayout.FloatField("Max Depth", profile.CrestMaxDepth);
                        profile.CrestFoamStrength = EditorGUILayout.Slider("Strength", profile.CrestFoamStrength, 0f, 1f);
                    }

                    if (water.MeshType == PWaterMeshType.Spline)
                    {
                        PEditorCommon.Header("Slope");
                        profile.SlopeFoamDistance  = EditorGUILayout.FloatField("Distance", profile.SlopeFoamDistance);
                        profile.SlopeFoamFlowSpeed = EditorGUILayout.FloatField("Flow Speed", profile.SlopeFoamFlowSpeed);
                        profile.SlopeFoamStrength  = EditorGUILayout.Slider("Strength", profile.SlopeFoamStrength, 0f, 1f);
                    }
                }
            });
        }
Esempio n. 17
0
        private void DrawEventsGUI()
        {
            string label = "Events";
            string id    = "events" + instance.GetInstanceID();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                SerializedObject so    = new SerializedObject(instance);
                SerializedProperty sp0 = so.FindProperty("onEnterWater");
                if (sp0 != null)
                {
                    EditorGUILayout.PropertyField(sp0);
                }

                SerializedProperty sp1 = so.FindProperty("onExitWater");
                if (sp1 != null)
                {
                    EditorGUILayout.PropertyField(sp1);
                }
                so.ApplyModifiedProperties();
            });
        }
Esempio n. 18
0
        private void DrawSelectedAnchorGUI()
        {
            int anchorIndex = splineEditingGUIDrawer.selectedAnchorIndex;

            if (anchorIndex < 0 ||
                anchorIndex >= water.Spline.Anchors.Count)
            {
                return;
            }
            string label = "Selected Anchor";
            string id    = "poseidon-selected-anchor";

            PEditorCommon.Foldout(label, true, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                PSplineAnchor a        = water.Spline.Anchors[anchorIndex];
                EditorGUI.BeginChangeCheck();
                a.Position = PEditorCommon.InlineVector3Field("Position", a.Position);
                a.Rotation = Quaternion.Euler(PEditorCommon.InlineVector3Field("Rotation", a.Rotation.eulerAngles));
                a.Scale    = PEditorCommon.InlineVector3Field("Scale", a.Scale);
                water.Spline.Anchors[anchorIndex] = a;
                if (EditorGUI.EndChangeCheck())
                {
                    if (PSplineToolConfig.Instance.AutoTangent)
                    {
                        int[] segmentIndices = water.Spline.SmoothTangents(anchorIndex);
                        water.GenerateSplineMeshAtSegments(segmentIndices);
                    }
                    else
                    {
                        List <int> segmentIndices = water.Spline.FindSegments(anchorIndex);
                        water.GenerateSplineMeshAtSegments(segmentIndices);
                    }
                }
                EditorGUI.indentLevel += 1;
            });
        }
        private void DrawUnderwaterGUI()
        {
            string label = "Underwater";
            string id    = "underwater" + instance.GetInstanceID();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                instance.EnableUnderwater = EditorGUILayout.Toggle("Enable", instance.EnableUnderwater);
                if (instance.EnableUnderwater)
                {
                    PEditorCommon.SpacePixel(0);
                    EditorGUILayout.LabelField("Water Body", PEditorCommon.BoldHeader);
                    instance.UnderwaterWaterLevel        = EditorGUILayout.FloatField("Water Level", instance.UnderwaterWaterLevel);
                    instance.UnderwaterMaxDepth          = EditorGUILayout.FloatField("Max Depth", instance.UnderwaterMaxDepth);
                    instance.UnderwaterSurfaceColorBoost = EditorGUILayout.Slider("Surface Color Boost", instance.UnderwaterSurfaceColorBoost, 1f, 3f);

                    PEditorCommon.SpacePixel(0);
                    EditorGUILayout.LabelField("Fog", PEditorCommon.BoldHeader);
                    instance.UnderwaterShallowFogColor = EditorGUILayout.ColorField("Shallow Fog Color", instance.UnderwaterShallowFogColor);
                    instance.UnderwaterDeepFogColor    = EditorGUILayout.ColorField("Deep Fog Color", instance.UnderwaterDeepFogColor);
                    instance.UnderwaterViewDistance    = EditorGUILayout.FloatField("View Distance", instance.UnderwaterViewDistance);

                    PEditorCommon.SpacePixel(0);
                    EditorGUILayout.LabelField("Caustic", PEditorCommon.BoldHeader);
                    instance.UnderwaterEnableCaustic = EditorGUILayout.Toggle("Enable", instance.UnderwaterEnableCaustic);
                    if (instance.UnderwaterEnableCaustic)
                    {
                        instance.UnderwaterCausticTexture  = PEditorCommon.InlineTextureField("Texture", instance.UnderwaterCausticTexture, -1);
                        instance.UnderwaterCausticSize     = EditorGUILayout.FloatField("Size", instance.UnderwaterCausticSize);
                        instance.UnderwaterCausticStrength = EditorGUILayout.Slider("Strength", instance.UnderwaterCausticStrength, 0f, 1f);
                    }

                    PEditorCommon.SpacePixel(0);
                    EditorGUILayout.LabelField("Distortion", PEditorCommon.BoldHeader);
                    instance.UnderwaterEnableDistortion = EditorGUILayout.Toggle("Enable", instance.UnderwaterEnableDistortion);
                    if (instance.UnderwaterEnableDistortion)
                    {
                        instance.UnderwaterDistortionTexture  = PEditorCommon.InlineTextureField("Normal Map", instance.UnderwaterDistortionTexture, -1);
                        instance.UnderwaterDistortionStrength = EditorGUILayout.FloatField("Strength", instance.UnderwaterDistortionStrength);
                        instance.UnderwaterWaterFlowSpeed     = EditorGUILayout.FloatField("Water Flow Speed", instance.UnderwaterWaterFlowSpeed);
                    }
                    PEditorCommon.Separator();
                }

                if (water != null && instance.EnableUnderwater)
                {
                    GUI.enabled = water.Profile != null;
                    if (GUILayout.Button("Inherit Parameters"))
                    {
                        instance.UnderwaterWaterLevel      = water.transform.position.y;
                        instance.UnderwaterMaxDepth        = water.Profile.MaxDepth;
                        instance.UnderwaterShallowFogColor = water.Profile.Color;
                        instance.UnderwaterDeepFogColor    = water.Profile.DepthColor;
                        instance.UnderwaterEnableCaustic   = water.Profile.EnableCaustic;
                        instance.UnderwaterCausticTexture  = water.Profile.CausticTexture;
                        instance.UnderwaterCausticSize     = water.Profile.CausticSize;
                        instance.UnderwaterCausticStrength = water.Profile.CausticStrength;
                    }
                    GUI.enabled = true;
                }
            });
        }