Ejemplo n.º 1
0
        protected void DrawLighting(ref bool updateMaterial)
        {
            DrawDefault("PowerRgb", ref updateMaterial, "Instead of just tinting the asteroids with the colors, should the RGB values be raised to the power of the color?");
            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                if (SgtLight.InstanceCount == 0)
                {
                    EditorGUILayout.HelpBox("You need to add the SgtLight component to your scene lights for them to work with SGT.", MessageType.Warning);
                }

                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                DrawDefault("AmbientColor", ref updateMaterial, "The belt will always be lit by this amount.");
                EndIndent();
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtBeltLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtBeltLightingTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnInspector()
        {
            var updateMesh     = false;
            var updateModel    = false;
            var updateMaterial = false;

            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateMesh, "This allows you to set the mesh used to render the flare.");
            EndError();
            BeginError(Any(t => t.Material == null));
            DrawDefault("Material", ref updateMaterial, "The material used to render this flare.");
            EndError();
            Draw("CameraOffset", "This allows you to offset the camera distance in world space when rendering the flare, giving you fine control over the render order."); // Updated automatically
            Draw("FollowCameras", "Should the flare automatically snap to cameras.");                                                                                      // Automatically updated

            if (Any(t => t.FollowCameras == true))
            {
                BeginIndent();
                BeginError(Any(t => t.FollowDistance <= 0.0f));
                Draw("FollowDistance", "The distance from the camera this flare will be placed in world space.");                                 // Automatically updated
                EndError();
                EndIndent();
            }

            if (Any(t => t.Mesh == null && t.GetComponent <SgtFlareMesh>() == null))
            {
                Separator();

                if (Button("Add Mesh") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtFlareMesh>(t.gameObject));
                }
            }

            if (Any(t => t.Material == null && t.GetComponent <SgtFlareMaterial>() == null))
            {
                Separator();

                if (Button("Add Material") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtFlareMaterial>(t.gameObject));
                }
            }

            if (updateMesh == true)
            {
                DirtyEach(t => t.UpdateMesh());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
        }
Ejemplo n.º 3
0
        protected void DrawPointMaterial(ref bool updateMaterial)
        {
            Separator();

            DrawDefault("PowerRgb", ref updateMaterial, "Instead of just tinting the stars with the colors, should the RGB values be raised to the power of the color?");

            DrawDefault("Stretch", ref updateMaterial, "Should the stars stretch if an observer moves?");

            if (Any(t => t.Stretch == true))
            {
                BeginIndent();
                DrawDefault("StretchVector", ref updateMaterial, "The vector of the stretching.");
                BeginError(Any(t => t.StretchScale < 0.0f));
                DrawDefault("StretchScale", ref updateMaterial, "The scale of the stretching relative to the velocity.");
                EndError();
                BeginError(Any(t => t.StretchLimit <= 0.0f));
                DrawDefault("StretchLimit", "When warping with the floating origin system the camera velocity can get too large, this allows you to limit it.");
                EndError();
                EndIndent();
            }

            DrawDefault("Pulse", ref updateMaterial, "Should the stars pulse in size over time?");

            if (Any(t => t.Pulse == true))
            {
                BeginIndent();
                DrawDefault("PulseOffset", "The amount of seconds this starfield has been animating.");
                BeginError(Any(t => t.PulseSpeed == 0.0f));
                DrawDefault("PulseSpeed", "The animation speed of this starfield.");
                EndError();
                EndIndent();
            }

            DrawDefault("Near", ref updateMaterial, "Should the stars fade out when the camera gets near?");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fading amount based on the distance.");
                EndError();
                BeginError(Any(t => t.NearThickness < 0.0f));
                DrawDefault("NearThickness", ref updateMaterial, "The thickness of the fading effect in world space.");
                EndError();
                EndIndent();
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtStarfieldNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtStarfieldNearTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 4
0
        protected void RequireCamera()
        {
            if (SgtCamera.InstanceCount == 0)
            {
                Separator();

                if (HelpButton("Your scene contains no SgtCameras", MessageType.Error, "Fix", 50.0f) == true)
                {
                    SgtHelper.ClearSelection();

                    foreach (var camera in Camera.allCameras)
                    {
                        SgtHelper.AddToSelection(camera.gameObject);

                        SgtHelper.GetOrAddComponent <SgtCamera>(camera.gameObject);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected void DrawLighting(ref bool updateMaterial)
        {
            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                EndIndent();
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtBeltLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtBeltLightingTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 6
0
        protected override void OnInspector()
        {
            var updateMaterial = false;
            var updateModel    = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the jovian material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The cube map used as the base texture for the jovian.");
            EndError();
            BeginError(Any(t => t.DepthTex == null));
            DrawDefault("DepthTex", ref updateMaterial, "The look up table associating optical depth with atmosphere color. The left side is used when the atmosphere is thin (e.g. edge of the jovian when looking from space). The right side is used when the atmosphere is thick (e.g. the center of the jovian when looking from space).");
            EndError();

            Separator();

            BeginError(Any(t => t.Sky < 0.0f));
            DrawDefault("Sky", "This allows you to control how thick the atmosphere is when the camera is inside its radius");                     // Updated when rendering
            EndError();

            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                DrawDefault("Scattering", ref updateMaterial, "If you enable this then light will scatter through the jovian atmosphere. This means light entering the eye will come from all angles, especially around the light point.");

                if (Any(t => t.Scattering == true))
                {
                    BeginIndent();
                    BeginError(Any(t => t.ScatteringTex == null));
                    DrawDefault("ScatteringTex", ref updateMaterial, "The look up table associating light angle with scattering color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                    EndError();
                    DrawDefault("ScatteringStrength", ref updateMaterial, "The scattering is multiplied by this value, allowing you to easily adjust the brightness of the effect.");
                    EndIndent();
                }
                EndIndent();
            }

            Separator();

            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateModel, "This allows you to set the mesh used to render the jovian. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.MeshRadius <= 0.0f));
            DrawDefault("MeshRadius", ref updateModel, "This allows you to set the radius of the Mesh. If this is incorrectly set then the jovian will render incorrectly.");
            EndError();
            BeginError(Any(t => t.Radius <= 0.0f));
            DrawDefault("Radius", ref updateModel, "This allows you to set the radius of the jovian in local space.");
            EndError();

            if (Any(t => t.DepthTex == null && t.GetComponent <SgtJovianDepthTex>() == null))
            {
                Separator();

                if (Button("Add DepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtJovianLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.Scattering == true && t.ScatteringTex == null && t.GetComponent <SgtJovianScatteringTex>() == null))
            {
                Separator();

                if (Button("Add ScatteringTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianScatteringTex>(t.gameObject));
                }
            }

            if (Any(t => SetMeshAndMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Mesh & MeshRadius") == true)
                {
                    Each(t => SetMeshAndMeshRadius(t, true));
                }
            }

            serializedObject.ApplyModifiedProperties();

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 7
0
        protected override void OnInspector()
        {
            var updateMaterials = false;
            var updateModel     = false;

            DrawDefault("Color", ref updateMaterials, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterials, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterials, "This allows you to adjust the render queue of the atmosphere materials. You can normally adjust the render queue in the material settings, but since these materials are procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.InnerDepthTex == null));
            DrawDefault("InnerDepthTex", ref updateMaterials, "The look up table associating optical depth with atmospheric color for the planet surface. The left side is used when the atmosphere is thin (e.g. center of the planet when looking from space). The right side is used when the atmosphere is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.InnerMeshRadius <= 0.0f));
            DrawDefault("InnerMeshRadius", ref updateMaterials, ref updateModel, "The radius of the meshes set in the SgtSharedMaterial.");
            EndError();

            Separator();

            BeginError(Any(t => t.OuterDepthTex == null));
            DrawDefault("OuterDepthTex", ref updateMaterials, "The look up table associating optical depth with atmospheric color for the planet sky. The left side is used when the atmosphere is thin (e.g. edge of the atmosphere when looking from space). The right side is used when the atmosphere is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.OuterMesh == null));
            DrawDefault("OuterMesh", ref updateModel, "This allows you to set the mesh used to render the atmosphere. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.OuterMeshRadius <= 0.0f));
            DrawDefault("OuterMeshRadius", ref updateModel, "This allows you to set the radius of the OuterMesh. If this is incorrectly set then the atmosphere will render incorrectly.");
            EndError();
            DrawDefault("OuterSoftness", ref updateMaterials, "If you have a big object that is both inside and outside of the atmosphere, it can cause a sharp intersection line. Increasing this setting allows you to change the smoothness of this intersection.");

            if (Any(t => t.OuterSoftness > 0.0f))
            {
                foreach (var camera in Camera.allCameras)
                {
                    if (SgtHelper.Enabled(camera) == true && camera.depthTextureMode == DepthTextureMode.None)
                    {
                        if ((camera.cullingMask & (1 << Target.gameObject.layer)) != 0)
                        {
                            if (HelpButton("You have enabled soft particles, but the '" + camera.name + "' camera does not write depth textures.", MessageType.Error, "Fix", 50.0f) == true)
                            {
                                var dtm = SgtHelper.GetOrAddComponent <SgtDepthTextureMode>(camera.gameObject);

                                dtm.DepthMode = DepthTextureMode.Depth;

                                dtm.UpdateDepthMode();

                                Selection.activeObject = dtm;
                            }
                        }
                    }
                }
            }

            Separator();

            BeginError(Any(t => t.Height <= 0.0f));
            DrawDefault("Height", ref updateMaterials, ref updateModel, "This allows you to set how high the atmosphere extends above the surface of the planet in local space.");
            EndError();
            BeginError(Any(t => t.InnerFog >= 1.0f));
            DrawDefault("InnerFog", ref updateMaterials, "This allows you to adjust the fog level of the atmosphere on the surface.");
            EndError();
            BeginError(Any(t => t.OuterFog >= 1.0f));
            DrawDefault("OuterFog", ref updateMaterials, "This allows you to adjust the fog level of the atmosphere in the sky.");
            EndError();
            BeginError(Any(t => t.Sky < 0.0f));
            DrawDefault("Sky", "This allows you to control how thick the atmosphere is when the camera is inside its radius");                                                                                           // Updated automatically
            EndError();
            DrawDefault("Middle", "This allows you to set the altitude where atmospheric density reaches its maximum point. The lower you set this, the foggier the horizon will appear when approaching the surface."); // Updated automatically
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the atmosphere, giving you fine control over the render order.");                                   // Updated automatically

            Separator();

            DrawDefault("Lit", ref updateMaterials, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                if (SgtLight.InstanceCount == 0)
                {
                    EditorGUILayout.HelpBox("You need to add the SgtLight component to your scene lights for them to work with SGT.", MessageType.Warning);
                }

                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterials, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                DrawDefault("AmbientColor", ref updateMaterials, "The atmosphere will always be lit by this amount.");
                DrawDefault("Scattering", ref updateMaterials, "If you enable this then light will scatter through the atmosphere. This means light entering the eye will come from all angles, especially around the light point.");
                if (Any(t => t.Scattering == true))
                {
                    BeginIndent();
                    DrawDefault("GroundScattering", ref updateMaterials, "If you enable this then atmospheric scattering will be applied to the surface material.");
                    BeginError(Any(t => t.ScatteringTex == null));
                    DrawDefault("ScatteringTex", ref updateMaterials, "The look up table associating light angle with scattering color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                    EndError();
                    DrawDefault("ScatteringStrength", ref updateMaterials, "The scattering is multiplied by this value, allowing you to easily adjust the brightness of the effect.");
                    DrawDefault("ScatteringMie", ref updateMaterials, "The mie scattering term, allowing you to adjust the distribution of front scattered light.");
                    DrawDefault("ScatteringRayleigh", ref updateMaterials, "The mie rayleigh term, allowing you to adjust the distribution of front and back scattered light.");
                    EndIndent();
                }
                DrawDefault("Night", "Should the night side of the atmosphere have different sky values?");                         // Updated automatically
                if (Any(t => t.Night == true))
                {
                    BeginIndent();
                    DrawDefault("NightSky", "The 'Sky' value of the night side.");                                              // Updated automatically
                    DrawDefault("NightEase", "The transition style between the day and night.");                                // Updated automatically
                    BeginError(Any(t => t.NightStart >= t.NightEnd));
                    DrawDefault("NightStart", "The start point of the day/sunset transition (0 = dark side, 1 = light side)."); // Updated automatically
                    DrawDefault("NightEnd", "The end point of the day/sunset transition (0 = dark side, 1 = light side).");     // Updated automatically
                    EndError();
                    BeginError(Any(t => t.NightPower < 1.0f));
                    DrawDefault("NightPower", "The power of the night transition.");                                             // Updated automatically
                    EndError();
                    EndIndent();
                }
                EndIndent();
            }

            if (Any(t => (t.InnerDepthTex == null || t.OuterDepthTex == null) && t.GetComponent <SgtAtmosphereDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtAtmosphereLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.Scattering == true && t.ScatteringTex == null && t.GetComponent <SgtAtmosphereScatteringTex>() == null))
            {
                Separator();

                if (Button("Add ScatteringTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereScatteringTex>(t.gameObject));
                }
            }

            if (Any(t => SetOuterMeshAndOuterMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Outer Mesh & Outer Mesh Radius") == true)
                {
                    Each(t => SetOuterMeshAndOuterMeshRadius(t, true));
                }
            }

            if (Any(t => AddInnerRendererAndSetInnerMeshRadius(t, false)))
            {
                Separator();

                if (Button("Add Inner Renderer & Set Inner Mesh Radius") == true)
                {
                    Each(t => AddInnerRendererAndSetInnerMeshRadius(t, true));
                }
            }

            if (updateMaterials == true)
            {
                DirtyEach(t => t.UpdateMaterials());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 8
0
        protected void DrawPointMaterial(ref bool dirtyMaterial)
        {
            Separator();

            Draw("powerRgb", ref dirtyMaterial, "Instead of just tinting the stars with the colors, should the RGB values be raised to the power of the color?");
            Draw("clampSize", ref dirtyMaterial, "Prevent the quads from being too small on screen?");
            if (Any(t => t.ClampSize == true))
            {
                BeginIndent();
                Draw("clampSizeMin", ref dirtyMaterial, "The minimum size each star can be on screen in pixels. If the star goes below this size, it loses opacity proportional to the amount it would have gone under.");
                EndIndent();
            }

            Draw("stretch", ref dirtyMaterial, "Should the stars stretch if an observer moves?");

            if (Any(t => t.Stretch == true))
            {
                BeginIndent();
                Draw("stretchVector", ref dirtyMaterial, "The vector of the stretching.");
                BeginError(Any(t => t.StretchScale < 0.0f));
                Draw("stretchScale", ref dirtyMaterial, "The scale of the stretching relative to the velocity.");
                EndError();
                BeginError(Any(t => t.StretchLimit <= 0.0f));
                Draw("stretchLimit", "When warping with the floating origin system the camera velocity can get too large, this allows you to limit it.");
                EndError();
                EndIndent();
            }

            Draw("pulse", ref dirtyMaterial, "Should the stars pulse in size over time?");

            if (Any(t => t.Pulse == true))
            {
                BeginIndent();
                Draw("pulseOffset", "The amount of seconds this starfield has been animating.");
                BeginError(Any(t => t.PulseSpeed == 0.0f));
                Draw("pulseSpeed", "The animation speed of this starfield.");
                EndError();
                EndIndent();
            }

            Draw("near", ref dirtyMaterial, "Should the stars fade out when the camera gets near?");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                Draw("nearTex", ref dirtyMaterial, "The lookup table used to calculate the fading amount based on the distance.");
                EndError();
                BeginError(Any(t => t.NearThickness < 0.0f));
                Draw("nearThickness", ref dirtyMaterial, "The thickness of the fading effect in world space.");
                EndError();
                EndIndent();
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtStarfieldNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtStarfieldNearTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 9
0
        protected override void OnInspector()
        {
            var updateMaterial = false;
            var updateModel    = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness <= 0.0f));
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the cloudsphere material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The cube map applied to the cloudsphere surface.");
            EndError();
            BeginError(Any(t => t.DepthTex == null));
            DrawDefault("DepthTex", ref updateMaterial, "The look up table associating optical depth with cloud color. The left side is used when the depth is thin (e.g. edge of the cloudsphere when looking from space). The right side is used when the depth is thick (e.g. center of the cloudsphere when looking from space).");
            EndError();
            BeginError(Any(t => t.Radius < 0.0f));
            DrawDefault("Radius", ref updateModel, "This allows you to set the radius of the cloudsphere in local space.");
            EndError();
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the cloudsphere, giving you fine control over the render order.");             // Updated automatically

            Separator();

            DrawDefault("Softness", ref updateMaterial, "Should the stars fade out if they're intersecting solid geometry?");

            if (Any(t => t.Softness > 0.0f))
            {
                foreach (var camera in Camera.allCameras)
                {
                    if (SgtHelper.Enabled(camera) == true && camera.depthTextureMode == DepthTextureMode.None)
                    {
                        if ((camera.cullingMask & (1 << Target.gameObject.layer)) != 0)
                        {
                            if (HelpButton("You have enabled soft particles, but the '" + camera.name + "' camera does not write depth textures.", MessageType.Error, "Fix", 50.0f) == true)
                            {
                                var dtm = SgtHelper.GetOrAddComponent <SgtDepthTextureMode>(camera.gameObject);

                                dtm.DepthMode = DepthTextureMode.Depth;

                                dtm.UpdateDepthMode();

                                Selection.activeObject = dtm;
                            }
                        }
                    }
                }
            }

            Separator();

            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                if (SgtLight.InstanceCount == 0)
                {
                    EditorGUILayout.HelpBox("You need to add the SgtLight component to your scene lights for them to work with SGT.", MessageType.Warning);
                }

                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Near", ref updateMaterial, "Enable this if you want the cloudsphere to fade out as the camera approaches.");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fade opacity based on distance, where the left side is used when the camera is close, and the right side is used when the camera is far.");
                EndError();
                BeginError(Any(t => t.NearDistance <= 0.0f));
                DrawDefault("NearDistance", ref updateMaterial, "The distance the fading begins from in world space.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Detail", ref updateMaterial, "");

            if (Any(t => t.Detail == true))
            {
                BeginIndent();
                BeginError(Any(t => t.DetailTex == null));
                DrawDefault("DetailTex", ref updateMaterial, "");
                EndError();
                BeginError(Any(t => t.DetailScale <= 0.0f));
                DrawDefault("DetailScale", ref updateMaterial, "");
                EndError();
                BeginError(Any(t => t.DetailTiling <= 0.0f));
                DrawDefault("DetailTiling", ref updateMaterial, "");
                EndError();
                EndIndent();
            }

            Separator();

            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateModel, "This allows you to set the mesh used to render the cloudsphere. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.MeshRadius <= 0.0f));
            DrawDefault("MeshRadius", ref updateModel, "This allows you to set the radius of the Mesh. If this is incorrectly set then the cloudsphere will render incorrectly.");
            EndError();

            if (Any(t => t.DepthTex == null && t.GetComponent <SgtCloudsphereDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtCloudsphereLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtCloudsphereNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereNearTex>(t.gameObject));
                }
            }

            if (Any(t => SetMeshAndMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Mesh & Mesh Radius") == true)
                {
                    Each(t => SetMeshAndMeshRadius(t, true));
                }
            }

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 10
0
        protected override void OnInspector()
        {
            var updateMaterials = false;
            var updateModel     = false;

            DrawDefault("Color", ref updateMaterials, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterials, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterials, "This allows you to adjust the render queue of the corona materials. You can normally adjust the render queue in the material settings, but since these materials are procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.InnerDepthTex == null));
            DrawDefault("InnerDepthTex", ref updateMaterials, "The look up table associating optical depth with coronal color for the star surface. The left side is used when the corona is thin (e.g. center of the star when looking from space). The right side is used when the corona is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.InnerMeshRadius <= 0.0f));
            DrawDefault("InnerMeshRadius", ref updateMaterials, ref updateModel, "The radius of the inner renderers (surface) in local coordinates.");
            EndError();

            Separator();

            BeginError(Any(t => t.OuterDepthTex == null));
            DrawDefault("OuterDepthTex", ref updateMaterials, "The look up table associating optical depth with coronal color for the star sky. The left side is used when the corona is thin (e.g. edge of the corona when looking from space). The right side is used when the corona is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.OuterMesh == null));
            DrawDefault("OuterMesh", ref updateModel, "This allows you to set the mesh used to render the atmosphere. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.OuterMeshRadius <= 0.0f));
            DrawDefault("OuterMeshRadius", ref updateModel, "This allows you to set the radius of the OuterMesh. If this is incorrectly set then the corona will render incorrectly.");
            EndError();

            Separator();

            BeginError(Any(t => t.Height <= 0.0f));
            DrawDefault("Height", ref updateMaterials, ref updateModel, "This allows you to set how high the corona extends above the surface of the star in local space.");
            EndError();
            BeginError(Any(t => t.InnerFog >= 1.0f));
            DrawDefault("InnerFog", ref updateMaterials, "If you want an extra-thin or extra-thick density, you can adjust that here (0 = default).");
            EndError();
            BeginError(Any(t => t.OuterFog >= 1.0f));
            DrawDefault("OuterFog", ref updateMaterials, "If you want an extra-thin or extra-thick density, you can adjust that here (0 = default).");
            EndError();
            BeginError(Any(t => t.Sky < 0.0f));
            DrawDefault("Sky", "This allows you to control how thick the corona is when the camera is inside its radius.");                                                        // Updated when rendering
            EndError();
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the corona, giving you fine control over the render order."); // Updated automatically

            if (Any(t => (t.InnerDepthTex == null || t.OuterDepthTex == null) && t.GetComponent <SgtCoronaDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCoronaDepthTex>(t.gameObject));
                }
            }

            if (Any(t => SetOuterMeshAndOuterMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set OuterMesh & OuterMeshRadius") == true)
                {
                    Each(t => SetOuterMeshAndOuterMeshRadius(t, true));
                }
            }

            if (Any(t => AddInnerRendererAndSetInnerMeshRadius(t, false)))
            {
                Separator();

                if (Button("Add InnerRenderer & Set InnerMeshRadius") == true)
                {
                    Each(t => AddInnerRendererAndSetInnerMeshRadius(t, true));
                }
            }

            if (updateMaterials == true)
            {
                DirtyEach(t => t.UpdateMaterials());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 11
0
        protected override void OnInspector()
        {
            var updateMaterials = false;
            var updateModel     = false;

            DrawDefault("Color", ref updateMaterials, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterials, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterials, "This allows you to adjust the render queue of the corona materials. You can normally adjust the render queue in the material settings, but since these materials are procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.InnerDepthTex == null));
            DrawDefault("InnerDepthTex", ref updateMaterials, "The look up table associating optical depth with coronal color for the star surface. The left side is used when the corona is thin (e.g. center of the star when looking from space). The right side is used when the corona is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.InnerMeshRadius <= 0.0f));
            DrawDefault("InnerMeshRadius", ref updateMaterials, ref updateModel, "The radius of the inner renderers (surface) in local coordinates.");
            EndError();

            Separator();

            BeginError(Any(t => t.OuterDepthTex == null));
            DrawDefault("OuterDepthTex", ref updateMaterials, "The look up table associating optical depth with coronal color for the star sky. The left side is used when the corona is thin (e.g. edge of the corona when looking from space). The right side is used when the corona is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.OuterMesh == null));
            DrawDefault("OuterMesh", ref updateModel, "This allows you to set the mesh used to render the atmosphere. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.OuterMeshRadius <= 0.0f));
            DrawDefault("OuterMeshRadius", ref updateModel, "This allows you to set the radius of the OuterMesh. If this is incorrectly set then the corona will render incorrectly.");
            EndError();
            DrawDefault("OuterSoftness", ref updateMaterials, "Should the outer corona fade out against intersecting geometry?");

            if (Any(t => t.OuterSoftness > 0.0f))
            {
                foreach (var camera in Camera.allCameras)
                {
                    if (SgtHelper.Enabled(camera) == true && camera.depthTextureMode == DepthTextureMode.None)
                    {
                        if ((camera.cullingMask & (1 << Target.gameObject.layer)) != 0)
                        {
                            if (HelpButton("You have enabled soft particles, but the '" + camera.name + "' camera does not write depth textures.", MessageType.Error, "Fix", 50.0f) == true)
                            {
                                var dtm = SgtHelper.GetOrAddComponent <SgtDepthTextureMode>(camera.gameObject);

                                dtm.DepthMode = DepthTextureMode.Depth;

                                dtm.UpdateDepthMode();

                                Selection.activeObject = dtm;
                            }
                        }
                    }
                }
            }

            Separator();

            BeginError(Any(t => t.Height <= 0.0f));
            DrawDefault("Height", ref updateMaterials, ref updateModel, "This allows you to set how high the corona extends above the surface of the star in local space.");
            EndError();
            BeginError(Any(t => t.InnerFog >= 1.0f));
            DrawDefault("InnerFog", ref updateMaterials, "If you want an extra-thin or extra-thick density, you can adjust that here (0 = default).");
            EndError();
            BeginError(Any(t => t.OuterFog >= 1.0f));
            DrawDefault("OuterFog", ref updateMaterials, "If you want an extra-thin or extra-thick density, you can adjust that here (0 = default).");
            EndError();
            BeginError(Any(t => t.Sky < 0.0f));
            Draw("Sky", "This allows you to control how thick the corona is when the camera is inside its radius.");                                                                                              // Updated when rendering
            EndError();
            Draw("Middle", "This allows you to set the altitude where atmospheric density reaches its maximum point. The lower you set this, the foggier the horizon will appear when approaching the surface."); // Updated automatically
            Draw("CameraOffset", "This allows you to offset the camera distance in world space when rendering the corona, giving you fine control over the render order.");                                       // Updated automatically

            if (Any(t => (t.InnerDepthTex == null || t.OuterDepthTex == null) && t.GetComponent <SgtCoronaDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCoronaDepthTex>(t.gameObject));
                }
            }

            if (Any(t => SetOuterMeshAndOuterMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set OuterMesh & OuterMeshRadius") == true)
                {
                    Each(t => SetOuterMeshAndOuterMeshRadius(t, true));
                }
            }

            if (Any(t => AddInnerRendererAndSetInnerMeshRadius(t, false)))
            {
                Separator();

                if (Button("Add InnerRenderer & Set InnerMeshRadius") == true)
                {
                    Each(t => AddInnerRendererAndSetInnerMeshRadius(t, true));
                }
            }

            if (updateMaterials == true)
            {
                DirtyEach(t => t.UpdateMaterials());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 12
0
        protected override void OnInspector()
        {
            var updateMaterial        = false;
            var updateMeshesAndModels = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the aurora material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the aurora, giving you fine control over the render order.");             // Updated automatically

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The base texture tiled along the aurora.");
            EndError();
            DrawDefault("Seed", ref updateMeshesAndModels, "This allows you to set the random seed used during procedural generation.");
            BeginError(Any(t => t.RadiusMin >= t.RadiusMax));
            DrawDefault("RadiusMin", ref updateMaterial, "The inner radius of the aurora mesh in local space.");
            DrawDefault("RadiusMax", ref updateMaterial, "The outer radius of the aurora mesh in local space.");
            EndError();

            Separator();

            BeginError(Any(t => t.PathCount < 1));
            DrawDefault("PathCount", ref updateMeshesAndModels, "The amount of aurora paths/ribbons.");
            EndError();
            BeginError(Any(t => t.PathDetail < 1));
            DrawDefault("PathDetail", ref updateMeshesAndModels, "The amount of quads used to build each path.");
            EndError();
            BeginError(Any(t => t.PathLengthMin > t.PathLengthMax));
            DrawDefault("PathLengthMin", ref updateMeshesAndModels, "The minimum length of each aurora path.");
            DrawDefault("PathLengthMax", ref updateMeshesAndModels, "The maximum length of each aurora path.");
            EndError();

            Separator();

            BeginError(Any(t => t.StartMin > t.StartMax));
            DrawDefault("StartMin", ref updateMeshesAndModels, "The minimum distance between the pole and the aurora path start point.");
            DrawDefault("StartMax", ref updateMeshesAndModels, "The maximum distance between the pole and the aurora path start point.");
            EndError();
            BeginError(Any(t => t.StartBias < 1.0f));
            DrawDefault("StartBias", ref updateMeshesAndModels, "The probability that the aurora path will begin closer to the pole.");
            EndError();
            DrawDefault("StartTop", ref updateMeshesAndModels, "The probability that the aurora path will start on the northern pole.");

            Separator();

            DrawDefault("PointDetail", ref updateMeshesAndModels, "The amount of waypoints the aurora path will follow based on its length.");
            DrawDefault("PointSpiral", ref updateMeshesAndModels, "The strength of the aurora waypoint twisting.");
            DrawDefault("PointJitter", ref updateMeshesAndModels, "The strength of the aurora waypoint random displacement.");

            Separator();

            DrawDefault("TrailTile", ref updateMeshesAndModels, "The amount of times the main texture is tiled based on its length.");
            BeginError(Any(t => t.TrailEdgeFade < 1.0f));
            DrawDefault("TrailEdgeFade", ref updateMeshesAndModels, "The sharpness of the fading at the start and ends of the aurora paths.");
            EndError();
            DrawDefault("TrailHeights", ref updateMeshesAndModels, "The flatness of the aurora path.");
            BeginError(Any(t => t.TrailHeightsDetail < 1));
            DrawDefault("TrailHeightsDetail", ref updateMeshesAndModels, "The amount of height changes in the aurora path.");
            EndError();

            Separator();

            DrawDefault("Colors", ref updateMeshesAndModels, "The possible colors given to the top half of the aurora path.");
            BeginError(Any(t => t.ColorsDetail < 1));
            DrawDefault("ColorsDetail", ref updateMeshesAndModels, "The amount of color changes an aurora path can have based on its length.");
            EndError();
            DrawDefault("ColorsAlpha", ref updateMeshesAndModels, "The minimum opacity multiplier of the aurora path colors.");
            DrawDefault("ColorsAlphaBias", ref updateMeshesAndModels, "The amount of alpha changes in the aurora path.");

            Separator();

            DrawDefault("Near", ref updateMaterial, "Should the aurora fade out when the camera gets near?");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fading amount based on the distance, where the left side is used when the camera is near, and the right side is used when the camera is far.");
                EndError();
                BeginError(Any(t => t.NearDistance < 0.0f));
                DrawDefault("NearDistance", ref updateMaterial, "The distance the fading begins from in world space.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Anim", ref updateMaterial, "Should the aurora paths animate?");

            if (Any(t => t.Anim == true))
            {
                BeginIndent();
                DrawDefault("AnimOffset", "The current age/offset of the animation.");                   // Updated automatically
                BeginError(Any(t => t.AnimSpeed == 0.0f));
                DrawDefault("AnimSpeed", "The speed of the animation.");                                 // Updated automatically
                EndError();
                DrawDefault("AnimStrength", ref updateMeshesAndModels, "The strength of the aurora path position changes in local space.");
                BeginError(Any(t => t.AnimStrengthDetail < 1));
                DrawDefault("AnimStrengthDetail", ref updateMeshesAndModels, "The amount of the animation strength changes along the aurora path based on its length.");
                EndError();
                DrawDefault("AnimAngle", ref updateMeshesAndModels, "The maximum angle step between sections of the aurora path.");
                BeginError(Any(t => t.AnimAngleDetail < 1));
                DrawDefault("AnimAngleDetail", ref updateMeshesAndModels, "The amount of the animation angle changes along the aurora path based on its length.");
                EndError();
                EndIndent();
            }

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateMeshesAndModels == true)
            {
                DirtyEach(t => t.UpdateMeshesAndModels());
            }

            if (Any(t => t.MainTex == null && t.GetComponent <SgtAuroraMainTex>() == null))
            {
                Separator();

                if (Button("Add MainTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAuroraMainTex>(t.gameObject));
                }
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtAuroraNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAuroraNearTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 13
0
        protected override void OnInspector()
        {
            var updateMaterial = false;
            var updateModels   = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the disc material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The texture applied to the accretion, where the left side is the inside, and the right side is the outside.");
            EndError();

            BeginError(Any(t => t.Segments < 1));
            DrawDefault("Segments", ref updateModels, ref updateModels, "This allows you to set how many copies of the Mesh are required to complete the disc. For example, if the Mesh is 1/4 of the ring, then Segments should be set to 4.");
            EndError();
            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateModels, "This allows you to set the mesh used to render the disc.");
            EndError();

            Separator();

            DrawDefault("Detail", ref updateMaterial, "Should the disc have a detail texture? For example, dust noise when you get close.");

            if (Any(t => t.Detail == true))
            {
                BeginIndent();
                BeginError(Any(t => t.DetailTex == null));
                DrawDefault("DetailTex", ref updateMaterial, "This allows you to set the detail texture that gets repeated on the disc surface.");
                EndError();
                BeginError(Any(t => t.DetailScaleX < 0.0f));
                DrawDefault("DetailScaleX", ref updateMaterial, "The detail texture horizontal tiling.");
                EndError();
                BeginError(Any(t => t.DetailScaleY < 1));
                DrawDefault("DetailScaleY", ref updateMaterial, "The detail texture vertical tiling.");
                EndError();
                DrawDefault("DetailOffset", ref updateMaterial, "The UV offset of the detail texture.");
                DrawDefault("DetailSpeed", ref updateMaterial, "The scroll speed of the detail texture UV offset.");
                DrawDefault("DetailTwist", ref updateMaterial, "The amount the detail texture is twisted around the disc.");
                BeginError(Any(t => t.DetailTwistBias < 1.0f));
                DrawDefault("DetailTwistBias", ref updateMaterial, "The amount the twisting is pushed to the outer edge.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Near", ref updateMaterial, "Enable this if you want the disc to fade out as the camera approaches.");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fade opacity based on distance, where the left side is used when the camera is close, and the right side is used when the camera is far.");
                EndError();
                BeginError(Any(t => t.NearDistance <= 0.0f));
                DrawDefault("NearDistance", ref updateMaterial, "The distance the fading begins from in world space.");
                EndError();
                EndIndent();
            }

            if (Any(t => t.Mesh == null && t.GetComponent <SgtAccretionMesh>() == null))
            {
                Separator();

                if (Button("Add Mesh") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAccretionMesh>(t.gameObject));
                }
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtAccretionNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAccretionNearTex>(t.gameObject));
                }
            }

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateModels == true)
            {
                DirtyEach(t => t.UpdateModels());
            }
        }
Ejemplo n.º 14
0
        protected override void OnInspector()
        {
            var updateMaterial        = false;
            var updateMeshesAndModels = false;

            DrawMaterial(ref updateMaterial);

            Separator();

            DrawMainTex(ref updateMaterial, ref updateMeshesAndModels);
            DrawLayout(ref updateMaterial, ref updateMeshesAndModels);

            Separator();

            DrawDefault("Softness", ref updateMaterial, "Should the stars fade out if they're intersecting solid geometry?");

            if (Any(t => t.Softness > 0.0f))
            {
                foreach (var camera in Camera.allCameras)
                {
                    if (SgtHelper.Enabled(camera) == true && camera.depthTextureMode == DepthTextureMode.None)
                    {
                        if ((camera.cullingMask & (1 << Target.gameObject.layer)) != 0)
                        {
                            if (HelpButton("You have enabled soft particles, but the '" + camera.name + "' camera does not write depth textures.", MessageType.Error, "Fix", 50.0f) == true)
                            {
                                var dtm = SgtHelper.GetOrAddComponent <SgtDepthTextureMode>(camera.gameObject);

                                dtm.DepthMode = DepthTextureMode.Depth;

                                dtm.UpdateDepthMode();

                                Selection.activeObject = dtm;
                            }
                        }
                    }
                }
            }

            DrawDefault("TetherPoint", "If you're using the floating origin system then set the floating point this starfield uses.");             // Updated automatically
            DrawDefault("TetherScale", "This allows you to set the SgtFloatingCamera.Scale that this starfield is being rendered with.");          // Updated automatically

            DrawPointMaterial(ref updateMaterial);

            DrawDefault("Far", ref updateMaterial, "Should the stars fade out when the camera gets too far away?");

            if (Any(t => t.Far == true))
            {
                BeginIndent();
                BeginError(Any(t => t.FarTex == null));
                DrawDefault("FarTex", ref updateMaterial, "The lookup table used to calculate the fading amount based on the distance.");
                EndError();
                BeginError(Any(t => t.FarRadius < 0.0f));
                DrawDefault("FarRadius", ref updateMaterial, "The radius of the fading effect in world space.");
                EndError();
                BeginError(Any(t => t.FarThickness <= 0.0f));
                DrawDefault("FarThickness", ref updateMaterial, "The thickness of the fading effect in world space.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Seed", ref updateMeshesAndModels, "This allows you to set the random seed used during procedural generation.");
            BeginError(Any(t => t.Size.x <= 0.0f || t.Size.y <= 0.0f || t.Size.z <= 0.0f));
            DrawDefault("Size", ref updateMeshesAndModels, ref updateMaterial, "The radius of the starfield.");
            EndError();

            Separator();

            BeginError(Any(t => t.StarCount < 0));
            DrawDefault("StarCount", ref updateMeshesAndModels, "The amount of stars that will be generated in the starfield.");
            EndError();
            DrawDefault("StarColors", ref updateMeshesAndModels, "Each star is given a random color from this gradient.");
            BeginError(Any(t => t.StarRadiusMin <0.0f || t.StarRadiusMin> t.StarRadiusMax));
            DrawDefault("StarRadiusMin", ref updateMeshesAndModels, "The minimum radius of stars in the starfield.");
            EndError();
            BeginError(Any(t => t.StarRadiusMax <0.0f || t.StarRadiusMin> t.StarRadiusMax));
            DrawDefault("StarRadiusMax", ref updateMeshesAndModels, "The maximum radius of stars in the starfield.");
            EndError();
            BeginError(Any(t => t.StarRadiusBias < 1.0f));
            DrawDefault("StarRadiusBias", ref updateMeshesAndModels, "How likely the size picking will pick smaller stars over larger ones (1 = default/linear).");
            EndError();
            DrawDefault("StarPulseMax", ref updateMeshesAndModels, "The maximum amount a star's size can pulse over time. A value of 1 means the star can potentially pulse between its maximum size, and 0.");

            RequireCamera();

            serializedObject.ApplyModifiedProperties();

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateMeshesAndModels == true)
            {
                DirtyEach(t => t.UpdateMeshesAndModels());
            }

            if (Any(t => t.Far == true && t.FarTex == null && t.GetComponent <SgtStarfieldInfiniteFarTex>() == null))
            {
                Separator();

                if (Button("Add FarTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtStarfieldInfiniteFarTex>(t.gameObject));
                }
            }
        }
Ejemplo n.º 15
0
        protected override void OnInspector()
        {
            Draw("color", "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            Draw("brightness", "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            Draw("renderQueue", "This allows you to adjust the render queue of the jovian material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");
            Draw("cameraOffset", "This allows you to offset the camera distance in world space when rendering the jovian, giving you fine control over the render order.");             // Updated automatically

            Separator();

            BeginError(Any(t => t.MainTex == null));
            Draw("mainTex", "The cube map used as the base texture for the jovian.");
            EndError();
            BeginError(Any(t => t.DepthTex == null));
            Draw("depthTex", "The look up table associating optical depth with atmosphere color. The left side is used when the atmosphere is thin (e.g. edge of the jovian when looking from space). The right side is used when the atmosphere is thick (e.g. the center of the jovian when looking from space).");
            EndError();
            Draw("flowTex", "The cube map used to define how the <b>MainTex</b> should flow across the surface of the jovian.");
            Draw("flowSpeed", "The speed of the jovian texture flow.");
            Draw("flowStrength", "The maximum distance the jovian texture can flow in UV space.");
            Draw("flowNoiseTiling", "The flow texture timing will be offset using noise, and this setting allows you to specify the resolution of that noise.");

            Separator();

            BeginError(Any(t => t.Sky < 0.0f));
            Draw("sky", "This allows you to control how thick the atmosphere is when the camera is inside its radius");                     // Updated when rendering
            EndError();

            Draw("lit", "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                if (SgtLight.InstanceCount == 0)
                {
                    EditorGUILayout.HelpBox("You need to add the SgtLight component to your scene lights for them to work with SGT.", MessageType.Warning);
                }

                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                Draw("lightingTex", "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                Draw("ambientColor", "The jovian will always be lit by this amount.");
                Draw("scattering", "If you enable this then light will scatter through the jovian atmosphere. This means light entering the eye will come from all angles, especially around the light point.");

                if (Any(t => t.Scattering == true))
                {
                    BeginIndent();
                    BeginError(Any(t => t.ScatteringTex == null));
                    Draw("scatteringTex", "The look up table associating light angle with scattering color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                    EndError();
                    Draw("scatteringStrength", "The scattering is multiplied by this value, allowing you to easily adjust the brightness of the effect.");
                    EndIndent();
                }
                EndIndent();
            }

            Separator();

            BeginError(Any(t => t.Mesh == null));
            Draw("mesh", "This allows you to set the mesh used to render the jovian. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.MeshRadius <= 0.0f));
            Draw("meshRadius", "This allows you to set the radius of the Mesh. If this is incorrectly set then the jovian will render incorrectly.");
            EndError();
            BeginError(Any(t => t.Radius <= 0.0f));
            Draw("radius", "This allows you to set the radius of the jovian in local space.");
            EndError();
            Draw("distanceRadius", "This allows you to set the radius of the jovian in local space when using distance calculations. Distance calculations normally tell you how far from the surface of a planet you are, but since a jovian isn't solid, you may want to customize this based on your project.");

            if (Any(t => t.DepthTex == null && t.GetComponent <SgtJovianDepthTex>() == null))
            {
                Separator();

                if (Button("Add DepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtJovianLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.Scattering == true && t.ScatteringTex == null && t.GetComponent <SgtJovianScatteringTex>() == null))
            {
                Separator();

                if (Button("Add ScatteringTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtJovianScatteringTex>(t.gameObject));
                }
            }

            if (Any(t => SetMeshAndMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Mesh & MeshRadius") == true)
                {
                    Each(t => SetMeshAndMeshRadius(t, true));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 16
0
        protected override void OnInspector()
        {
            var updateMaterials = false;
            var updateModel     = false;

            DrawDefault("Color", ref updateMaterials, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterials, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterials, "This allows you to adjust the render queue of the atmosphere materials. You can normally adjust the render queue in the material settings, but since these materials are procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.InnerDepthTex == null));
            DrawDefault("InnerDepthTex", ref updateMaterials, "The look up table associating optical depth with atmospheric color for the planet surface. The left side is used when the atmosphere is thin (e.g. center of the planet when looking from space). The right side is used when the atmosphere is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.InnerMeshRadius <= 0.0f));
            DrawDefault("InnerMeshRadius", ref updateMaterials, ref updateModel, "The radius of the meshes set in the SgtSharedMaterial.");
            EndError();

            Separator();

            BeginError(Any(t => t.OuterDepthTex == null));
            DrawDefault("OuterDepthTex", ref updateMaterials, "The look up table associating optical depth with atmospheric color for the planet sky. The left side is used when the atmosphere is thin (e.g. edge of the atmosphere when looking from space). The right side is used when the atmosphere is thick (e.g. the horizon).");
            EndError();
            BeginError(Any(t => t.OuterMeshRadius <= 0.0f));
            DrawDefault("OuterMeshRadius", ref updateModel, "This allows you to set the radius of the OuterMesh. If this is incorrectly set then the atmosphere will render incorrectly.");
            EndError();
            BeginError(Any(t => t.OuterMesh == null));
            DrawDefault("OuterMesh", ref updateModel, "This allows you to set the mesh used to render the atmosphere. This should be a sphere.");
            EndError();

            Separator();

            BeginError(Any(t => t.Height <= 0.0f));
            DrawDefault("Height", ref updateMaterials, ref updateModel, "This allows you to set how high the atmosphere extends above the surface of the planet in local space.");
            EndError();
            BeginError(Any(t => t.InnerFog >= 1.0f));
            DrawDefault("InnerFog", ref updateMaterials, "This allows you to adjust the fog level of the atmosphere on the surface.");
            EndError();
            BeginError(Any(t => t.OuterFog >= 1.0f));
            DrawDefault("OuterFog", ref updateMaterials, "This allows you to adjust the fog level of the atmosphere in the sky.");
            EndError();
            BeginError(Any(t => t.Sky < 0.0f));
            DrawDefault("Sky", "This allows you to control how thick the atmosphere is when the camera is inside its radius");                                                         // Updated when rendering
            EndError();
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the atmosphere, giving you fine control over the render order."); // Updated automatically

            Separator();

            DrawDefault("Lit", ref updateMaterials, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterials, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                DrawDefault("Scattering", ref updateMaterials, "If you enable this then light will scatter through the atmosphere. This means light entering the eye will come from all angles, especially around the light point.");
                if (Any(t => t.Scattering == true))
                {
                    BeginIndent();
                    DrawDefault("GroundScattering", ref updateMaterials, "If you enable this then atmospheric scattering will be applied to the surface material.");
                    BeginError(Any(t => t.ScatteringTex == null));
                    DrawDefault("ScatteringTex", ref updateMaterials, "The look up table associating light angle with scattering color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                    EndError();
                    DrawDefault("ScatteringStrength", ref updateMaterials, "The scattering is multiplied by this value, allowing you to easily adjust the brightness of the effect.");
                    DrawDefault("ScatteringMie", ref updateMaterials, "The mie scattering term, allowing you to adjust the distribution of front scattered light.");
                    DrawDefault("ScatteringRayleigh", ref updateMaterials, "The mie rayleigh term, allowing you to adjust the distribution of front and back scattered light.");
                    EndIndent();
                }
                DrawDefault("Night");                         // Updated automatically
                if (Any(t => t.Night == true))
                {
                    BeginIndent();
                    DrawDefault("NightSky");                             // Updated automatically
                    DrawDefault("NightEase");                            // Updated automatically
                    BeginError(Any(t => t.NightStart >= t.NightEnd));
                    DrawDefault("NightStart");                           // Updated automatically
                    DrawDefault("NightEnd");                             // Updated automatically
                    EndError();
                    BeginError(Any(t => t.NightPower < 1.0f));
                    DrawDefault("NightPower");                                     // Updated automatically
                    EndError();
                    EndIndent();
                }
                EndIndent();
            }

            if (Any(t => (t.InnerDepthTex == null || t.OuterDepthTex == null) && t.GetComponent <SgtAtmosphereDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtAtmosphereLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.Scattering == true && t.ScatteringTex == null && t.GetComponent <SgtAtmosphereScatteringTex>() == null))
            {
                Separator();

                if (Button("Add ScatteringTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtAtmosphereScatteringTex>(t.gameObject));
                }
            }

            if (Any(t => SetOuterMeshAndOuterMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Outer Mesh & Outer Mesh Radius") == true)
                {
                    Each(t => SetOuterMeshAndOuterMeshRadius(t, true));
                }
            }

            if (Any(t => AddInnerRendererAndSetInnerMeshRadius(t, false)))
            {
                Separator();

                if (Button("Add Inner Renderer & Set Inner Mesh Radius") == true)
                {
                    Each(t => AddInnerRendererAndSetInnerMeshRadius(t, true));
                }
            }

            if (updateMaterials == true)
            {
                DirtyEach(t => t.UpdateMaterials());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }
Ejemplo n.º 17
0
        protected override void OnInspector()
        {
            var dirtyMaterial = false;

            Draw("color", ref dirtyMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            Draw("brightness", ref dirtyMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            Draw("renderQueue", ref dirtyMaterial, "This allows you to adjust the render queue of the spacetime material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            Draw("center", "The center of the spacetime grid in local space.");
            BeginError(Any(t => t.Size == Vector2.zero));
            Draw("size", "The size of the spacetime grid in local space.");
            EndError();
            BeginError(Any(t => t.Mesh == null));
            Draw("mesh", "The mesh used to render the spacetime.");
            EndError();
            BeginError(Any(t => t.MainTex == null));
            Draw("mainTex", ref dirtyMaterial, "The main texture applied to the spacetime.");
            EndError();
            BeginError(Any(t => t.Tile <= 0));
            Draw("tile", ref dirtyMaterial, "How many times should the spacetime texture be tiled?");
            EndError();

            Separator();

            Draw("ambientColor", ref dirtyMaterial, "The ambient color.");
            BeginError(Any(t => t.AmbientBrightness < 0.0f));
            Draw("ambientBrightness", ref dirtyMaterial, "The ambient brightness.");
            EndError();

            Separator();

            Draw("displacementColor", ref dirtyMaterial, "The displacement color.");
            BeginError(Any(t => t.DisplacementBrightness < 0.0f));
            Draw("displacementBrightness", ref dirtyMaterial, "The displacement brightness.");
            EndError();

            Separator();

            Draw("highlightColor", ref dirtyMaterial, "The color of the highlight.");
            Draw("highlightBrightness", ref dirtyMaterial, "The brightness of the highlight.");
            Draw("highlightScale", ref dirtyMaterial, "The scale of the highlight.");
            BeginError(Any(t => t.HighlightPower < 0.0f));
            Draw("highlightPower", ref dirtyMaterial, "The sharpness of the highlight.");
            EndError();

            Separator();

            Draw("displacement", ref dirtyMaterial, "How should the vertices in the spacetime get displaced when a well is nearby?");
            BeginIndent();
            Draw("accumulate", ref dirtyMaterial, "Should the displacement effect additively stack if wells overlap?");

            if (Any(t => t.Displacement == SgtSpacetime.DisplacementType.Pinch))
            {
                BeginError(Any(t => t.Power < 0.0f));
                Draw("power", ref dirtyMaterial, "The pinch power.");
                EndError();
            }

            if (Any(t => t.Displacement == SgtSpacetime.DisplacementType.Offset))
            {
                Draw("offset", ref dirtyMaterial, "The offset direction/vector for vertices within range of a well.");
            }
            EndIndent();

            Separator();

            Draw("requireSameLayer", "Filter all the wells to require the same layer at this GameObject.");
            Draw("requireSameTag", "Filter all the wells to require the same tag at this GameObject.");
            Draw("requireNameContains", "Filter all the wells to require a name that contains this.");

            if (Any(t => t.Mesh == null && t.GetComponent <SgtSpacetimeMesh>() == null))
            {
                Separator();

                if (Button("Add Mesh") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtSpacetimeMesh>(t.gameObject));
                }
            }

            if (dirtyMaterial == true)
            {
                DirtyEach(t => t.DirtyMaterial());
            }
        }
Ejemplo n.º 18
0
        protected override void OnInspector()
        {
            var dirtyMesh = false;

            BeginError(Any(t => t.Mesh == null));
            Draw("mesh", ref dirtyMesh, "The sphere mesh used to render the planet.");
            EndError();
            //Draw("renderingLayer", "The rendering layer used to render the planet.");
            Draw("meshCollider", ref dirtyMesh, "If you want the generated mesh to have a matching collider, you can specify it here.");
            BeginError(Any(t => t.Radius <= 0.0f));
            Draw("radius", ref dirtyMesh, "The radius of the planet in local space.");
            EndError();

            Separator();

            BeginError(Any(t => t.Material == null));
            Draw("material", "The material used to render the planet. For best results, this should use the SGT Planet shader.");
            EndError();
            Draw("sharedMaterial", "If you want to apply a shared material (e.g. atmosphere) to this terrain, then specify it here.");

            Separator();

            if (Any(t => t.MaterialHeightmap != null))
            {
                if (Any(t => t.MaterialHasWater == true))
                {
                    Draw("waterLevel", ref dirtyMesh, "The current water level.\n\n0 = Radius.\n\n1 = Radius + Displacement.");
                }
                Draw("displace", ref dirtyMesh, "Should the planet mesh be displaced using the heightmap in the planet material?");
                if (Any(t => t.Displace == true))
                {
                    BeginIndent();
                    BeginError(Any(t => t.Displacement == 0.0f));
                    Draw("displacement", ref dirtyMesh, "The maximum height displacement applied to the planet mesh when the heightmap alpha value is 1.");
                    EndError();
                    Draw("clampWater", ref dirtyMesh, "If you enable this then the water will not rise, instead the terrain will shrink down.");
                    EndIndent();
                }
            }

            if (Any(t => t.MaterialHasWater == true && t.GetComponent <SgtPlanetWaterGradient>() == null))
            {
                Separator();

                if (HelpButton("This material has water, but you have no WaterGradient component.", MessageType.Info, "Fix", 50) == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtPlanetWaterGradient>(t.gameObject));
                }
            }

            if (Any(t => t.MaterialHasWater == true && t.GetComponent <SgtPlanetWaterTexture>() == null))
            {
                Separator();

                if (HelpButton("This material has water, but you have no WaterTexture component.", MessageType.Info, "Fix", 50) == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtPlanetWaterTexture>(t.gameObject));
                }
            }

            if (dirtyMesh == true)
            {
                DirtyEach(t => t.DirtyMesh());
            }
        }
Ejemplo n.º 19
0
        protected override void OnInspector()
        {
            var updateMaterial = false;
            var updateModels   = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness < 0.0f));
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the ring material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The texture applied to the ring, where the left side is the inside, and the right side is the outside.");
            EndError();

            BeginError(Any(t => t.Segments < 1));
            DrawDefault("Segments", ref updateModels, ref updateModels, "This allows you to set how many copies of the Mesh are required to complete the ring. For example, if the Mesh is 1/4 of the ring, then Segments should be set to 4.");
            EndError();
            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateModels, "This allows you to set the mesh used to render the ring.");
            EndError();

            Separator();

            DrawDefault("Detail", ref updateMaterial, "Should the ring have a detail texture? For example, dust noise when you get close.");

            if (Any(t => t.Detail == true))
            {
                BeginIndent();
                BeginError(Any(t => t.DetailTex == null));
                DrawDefault("DetailTex", ref updateMaterial, "This allows you to set the detail texture that gets repeated on the ring surface.");
                EndError();
                BeginError(Any(t => t.DetailScaleX < 0.0f));
                DrawDefault("DetailScaleX", ref updateMaterial, "The detail texture horizontal tiling.");
                EndError();
                BeginError(Any(t => t.DetailScaleY < 1));
                DrawDefault("DetailScaleY", ref updateMaterial, "The detail texture vertical tiling.");
                EndError();
                DrawDefault("DetailOffset", ref updateMaterial, "The UV offset of the detail texture.");
                DrawDefault("DetailSpeed", ref updateMaterial, "The scroll speed of the detail texture UV offset.");
                DrawDefault("DetailTwist", ref updateMaterial, "The amount the detail texture is twisted around the ring.");
                BeginError(Any(t => t.DetailTwistBias < 1.0f));
                DrawDefault("DetailTwistBias", ref updateMaterial, "The amount the twisting is pushed to the outer edge.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Near", ref updateMaterial, "Enable this if you want the ring to fade out as the camera approaches.");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fade opacity based on distance, where the left side is used when the camera is close, and the right side is used when the camera is far.");
                EndError();
                BeginError(Any(t => t.NearDistance <= 0.0f));
                DrawDefault("NearDistance", ref updateMaterial, "The distance the fading begins from in world space.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                if (SgtLight.InstanceCount == 0)
                {
                    EditorGUILayout.HelpBox("You need to add the SgtLight component to your scene lights for them to work with SGT.", MessageType.Warning);
                }

                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                DrawDefault("Scattering", ref updateMaterial, "If you enable this then light will scatter through the ring atmosphere. This means light entering the eye will come from all angles, especially around the light point.");

                if (Any(t => t.Scattering == true))
                {
                    BeginIndent();
                    BeginError(Any(t => t.ScatteringMie <= 0.0f));
                    DrawDefault("ScatteringMie", ref updateMaterial, "The mie scattering term, allowing you to adjust the distribution of front scattered light.");
                    EndError();
                    DrawDefault("ScatteringStrength", "The scattering is multiplied by this value, allowing you to easily adjust the brightness of the effect.");                                     // Updated in LateUpdate
                    EndIndent();
                }
                EndIndent();
            }

            if (Any(t => t.Mesh == null && t.GetComponent <SgtRingMesh>() == null))
            {
                Separator();

                if (Button("Add Mesh") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtRingMesh>(t.gameObject));
                }
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtRingNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtRingNearTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtRingLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtRingLightingTex>(t.gameObject));
                }
            }

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateModels == true)
            {
                DirtyEach(t => t.UpdateModels());
            }
        }
Ejemplo n.º 20
0
        protected override void OnInspector()
        {
            var updateMaterial = false;
            var updateModel    = false;

            DrawDefault("Color", ref updateMaterial, "The base color will be multiplied by this.");
            BeginError(Any(t => t.Brightness <= 0.0f));
            DrawDefault("Brightness", ref updateMaterial, "The Color.rgb values are multiplied by this, allowing you to quickly adjust the overall brightness.");
            EndError();
            DrawDefault("RenderQueue", ref updateMaterial, "This allows you to adjust the render queue of the cloudsphere material. You can normally adjust the render queue in the material settings, but since this material is procedurally generated your changes will be lost.");

            Separator();

            BeginError(Any(t => t.MainTex == null));
            DrawDefault("MainTex", ref updateMaterial, "The cube map applied to the cloudsphere surface.");
            EndError();
            BeginError(Any(t => t.DepthTex == null));
            DrawDefault("DepthTex", ref updateMaterial, "The look up table associating optical depth with cloud color. The left side is used when the depth is thin (e.g. edge of the cloudsphere when looking from space). The right side is used when the depth is thick (e.g. center of the cloudsphere when looking from space).");
            EndError();
            BeginError(Any(t => t.Radius < 0.0f));
            DrawDefault("Radius", ref updateModel, "This allows you to set the radius of the cloudsphere in local space.");
            EndError();
            DrawDefault("CameraOffset", "This allows you to offset the camera distance in world space when rendering the cloudsphere, giving you fine control over the render order.");             // Updated automatically

            Separator();

            DrawDefault("Lit", ref updateMaterial, "If you enable this then nearby SgtLight and SgtShadow casters will be found and applied to the lighting calculations.");

            if (Any(t => t.Lit == true))
            {
                BeginIndent();
                BeginError(Any(t => t.LightingTex == null));
                DrawDefault("LightingTex", ref updateMaterial, "The look up table associating light angle with surface color. The left side is used on the dark side, the middle is used on the horizon, and the right side is used on the light side.");
                EndError();
                EndIndent();
            }

            Separator();

            DrawDefault("Near", ref updateMaterial, "Enable this if you want the cloudsphere to fade out as the camera approaches.");

            if (Any(t => t.Near == true))
            {
                BeginIndent();
                BeginError(Any(t => t.NearTex == null));
                DrawDefault("NearTex", ref updateMaterial, "The lookup table used to calculate the fade opacity based on distance, where the left side is used when the camera is close, and the right side is used when the camera is far.");
                EndError();
                BeginError(Any(t => t.NearDistance <= 0.0f));
                DrawDefault("NearDistance", ref updateMaterial, "The distance the fading begins from in world space.");
                EndError();
                EndIndent();
            }

            Separator();

            BeginError(Any(t => t.Mesh == null));
            DrawDefault("Mesh", ref updateModel, "This allows you to set the mesh used to render the cloudsphere. This should be a sphere.");
            EndError();
            BeginError(Any(t => t.MeshRadius <= 0.0f));
            DrawDefault("MeshRadius", ref updateModel, "This allows you to set the radius of the Mesh. If this is incorrectly set then the cloudsphere will render incorrectly.");
            EndError();

            if (Any(t => t.DepthTex == null && t.GetComponent <SgtCloudsphereDepthTex>() == null))
            {
                Separator();

                if (Button("Add InnerDepthTex & OuterDepthTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereDepthTex>(t.gameObject));
                }
            }

            if (Any(t => t.Lit == true && t.LightingTex == null && t.GetComponent <SgtCloudsphereLightingTex>() == null))
            {
                Separator();

                if (Button("Add LightingTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereLightingTex>(t.gameObject));
                }
            }

            if (Any(t => t.Near == true && t.NearTex == null && t.GetComponent <SgtCloudsphereNearTex>() == null))
            {
                Separator();

                if (Button("Add NearTex") == true)
                {
                    Each(t => SgtHelper.GetOrAddComponent <SgtCloudsphereNearTex>(t.gameObject));
                }
            }

            if (Any(t => SetMeshAndMeshRadius(t, false)))
            {
                Separator();

                if (Button("Set Mesh & Mesh Radius") == true)
                {
                    Each(t => SetMeshAndMeshRadius(t, true));
                }
            }

            if (updateMaterial == true)
            {
                DirtyEach(t => t.UpdateMaterial());
            }
            if (updateModel == true)
            {
                DirtyEach(t => t.UpdateModel());
            }
        }