Esempio n. 1
0
    protected override void Update()
    {
        base.Update();

        CheckCutoff();

        if (LODTarget != null)
        {
            DistanceToLODTarget = PlanetBounds.SqrDistance(LODTarget.position);
        }
        else
        {
            DistanceToLODTarget = -1.0f;
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            DrawNormals = !DrawNormals;

            //NOTE : Update shader variable...
            MPB.SetFloat("_DrawNormals", DrawNormals ? 1.0f : 0.0f);
        }

        if (Input.GetKeyDown(KeyCode.F2))
        {
            DrawQuadTree = !DrawQuadTree;

            //NOTE : Update shader variable...
            MPB.SetFloat("_DrawQuadTree", DrawQuadTree ? 1.0f : 0.0f);
        }

        if (Input.GetKeyDown(KeyCode.F3))
        {
            if (Atmosphere != null)
            {
                Atmosphere.Bake();
            }
        }

        if (Input.GetKeyDown(KeyCode.F4))
        {
            if (Atmosphere != null)
            {
                Atmosphere.Reanimate();
            }
        }

        if (Atmosphere != null)
        {
            Atmosphere.SetUniforms(MPB);                     // TODO : Full? Really?
        }
        if (!ExternalRendering)
        {
            Render();
        }

        UpdateLOD();
    }
Esempio n. 2
0
        protected override void UI(int id)
        {
            GUILayoutExtensions.VerticalBoxed("Controls: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawApplyButton(() => { if (Body != null && Atmosphere != null)
                                            {
                                                Atmosphere.Bake();
                                            }
                                    });
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            if (Body != null && Helper.Enabled(Body))
            {
                if (Atmosphere != null && Helper.Enabled(Body.Atmosphere) && Body.AtmosphereEnabled)
                {
                    GUILayoutExtensions.VerticalBoxed("Realtime parameters: ", GUISkin, () =>
                    {
                        GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                        {
                            GUILayoutExtensions.VerticalBoxed("Preset: ", GUISkin, () =>
                            {
                                Atmosphere.AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)Atmosphere.AtmosphereBase, Enum.GetNames(typeof(AtmosphereBase)), 2);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            GUILayoutExtensions.VerticalBoxed("Artifact fixers: ", GUISkin, () =>
                            {
                                GUILayoutExtensions.SliderWithField("Radius Hold (Terrain Radius)", 0.0f, 2048.0f, ref Atmosphere.RadiusHold, "0.00", 75);
                                GUILayoutExtensions.SliderWithField("Aerial Radius (Perspective Offset)", 0.0f, 4096.0f, ref Atmosphere.AerialPerspectiveOffset, "0.00", 75);
                                GUILayoutExtensions.SliderWithFieldAndControls("Horizon Fix Eps", 0.0f, 1.0f, ref Atmosphere.HorizonFixEps, "0.00000", 75, 0.00025f);
                                GUILayoutExtensions.SliderWithFieldAndControls("Mie Fade Fix", 0.0f, 1.0f, ref Atmosphere.MieFadeFix, "0.0000", 75, 0.0025f);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            GUILayoutExtensions.SliderWithField("Density: ", 0.0f, 1.0f, ref Atmosphere.Density);
                            GUILayoutExtensions.SliderWithField("Scale", 0.01f, 16.0f, ref Atmosphere.Scale, "0.000");
                            GUILayoutExtensions.SliderWithField("Height: ", 0.0f, Body.Size, ref Atmosphere.Height);
                            GUILayoutExtensions.SliderWithField("Extinction Ground Fade", 0.000025f, 0.1f, ref Atmosphere.ExtinctionGroundFade, "0.000000");
                            GUILayoutExtensions.SliderWithField("HDR Exposure", 0.0f, 1.0f, ref Atmosphere.HDRExposure, "0.00");
                        });
                    });

                    GUILayoutExtensions.SpacingSeparator();

                    if (Atmosphere.AtmosphereBase == AtmosphereBase.Custom)
                    {
                        GUILayoutExtensions.VerticalBoxed("Bake parameters: ", GUISkin, () =>
                        {
                            GUILayoutExtensions.VerticalBoxed("Copy from preset: ", GUISkin, () =>
                            {
                                AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)AtmosphereBase, Enum.GetNames(typeof(AtmosphereBase)), 2);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            var parameters = PresetChanged ? AtmosphereParameters.Get(AtmosphereBase) : new AtmosphereParameters(AtmosphereParameters);

                            var mieG  = parameters.MIE_G;
                            var hr    = parameters.HR;
                            var hm    = parameters.HM;
                            var agr   = parameters.AVERAGE_GROUND_REFLECTANCE;
                            var betaR = parameters.BETA_R;
                            var betaM = parameters.BETA_MSca;
                            var betaE = parameters.BETA_MEx;
                            var rg    = parameters.Rg;
                            var rt    = parameters.Rt;
                            var rl    = parameters.Rl;

                            PresetChanged = false;

                            GUILayoutExtensions.SliderWithField("Mie G: ", 0.0f, 1.0f, ref mieG, "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithFieldAndControls("Air density (HR At half-height in KM): ", 0.0f, 256.0f, ref hr, "0.00", textFieldWidth: 100, controlStep: 1.0f);
                            GUILayoutExtensions.SliderWithFieldAndControls("Particle density (HM At half-height in KM): ", 0.0f, 256.0f, ref hm, "0.00", textFieldWidth: 100, controlStep: 1.0f);
                            GUILayoutExtensions.SliderWithField("Average Ground Reflectance: ", 0.0f, 1.0f, ref agr, "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rg (Planet Radius in KM): ", 0.0f, 63600.0f, ref rg, "0.00000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rt (Atmosphere Top Radius in KM): ", rg, 63600.0f, ref rt, "0.00000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rl (Planet Bottom Radius in KM): ", rt, 63600.0f, ref rl, "0.00000", textFieldWidth: 100);

                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaR, 0.0f, 1.0f, GUISkin, "Beta R (Rayliegh Scattering)", "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaM, 0.0f, 1.0f, GUISkin, "Beta M (Mie Scattering)", "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaE, 0.0f, 1.0f, GUISkin, "Beta E (Extinction Scattering)", "0.0000", textFieldWidth: 100);

                            parameters = new AtmosphereParameters(mieG, hr, hm, agr, betaR, betaM, betaE, rg, rt, rl, rg, rt, rl, SCALE: 1.0f);

                            AtmosphereParameters = new AtmosphereParameters(parameters);
                            Atmosphere.PushPreset(parameters);
                        });
                    }
                    else
                    {
                        GUILayoutExtensions.DrawBadHolder("Atmosphere Bake parameters: ", "Use 'Custom' preset please...", GUISkin);
                    }
                }
                else
                {
                    GUILayoutExtensions.DrawBadHolder("Atmosphere parameters: ", "No Atmosphere!?", GUISkin);
                }
            }
            else
            {
                GUILayoutExtensions.DrawBadHolder("Atmosphere parameters: ", "No Body!?", GUISkin);
            }

            GUILayout.EndScrollView();
        }