Esempio n. 1
0
        private void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (!m_IsReady)
            {
                Graphics.Blit(source, destination);
                enabled = false;
                return;
            }

            FXMaterial.SetMatrix(m_FrustumCornersID, FrustumCorners());
            FXMaterial.SetVector(m_CameraPositionID, m_CameraTransform.position);

            FXMaterial.SetFloat(m_SunMiePhaseDepthMultiplierID, m_SunMiePhaseDepthMultiplier);
            FXMaterial.SetFloat(m_MoonMiePhaseDepthMultiplierID, m_MoonMiePhaseDepthMultiplier);
            FXMaterial.SetFloat(m_RayleighDepthMultiplierID, m_RayleighDepthMultiplier);
            FXMaterial.SetFloat(m_FogBlendColorID, m_BlendColor);
            FXMaterial.SetFloat(m_FogSmoothColorID, m_SmoothColor);
            FXMaterial.SetFloat(m_FogSunMiePhaseMultID, m_SunMiePhaseMult);
            FXMaterial.SetFloat(m_FogMoonMiePhaseMultID, m_MoonMiePhaseMult);

            int pass = 0;

            switch (m_FogMode)
            {
            case FogMode.Linear:

                pass = 0;

                Vector2 lp;
                lp.x = m_StartDistance;
                lp.y = m_EndDistance;
                FXMaterial.SetVector("lsky_FogLinearParams", lp);

                break;

            case FogMode.Exponential:

                pass = 1;

                float densityExp = m_Density * 1.4426950408f;
                FXMaterial.SetFloat("lsky_FogDensity", densityExp);

                break;

            case FogMode.ExponentialSquared:

                pass = 2;

                float densityExp2 = m_Density * 1.2011224087f;
                FXMaterial.SetFloat("lsky_FogDensity", densityExp2);

                break;
            }

            CustomBlit(source, destination, FXMaterial, pass);
        }
Esempio n. 2
0
        private void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (!m_IsReady)
            {
                Graphics.Blit(source, destination);
                enabled = false;
                return;
            }

            FXMaterial.SetMatrix(m_FrustumCornersID, FrustumCorners());
            FXMaterial.SetVector(m_CameraPositionID, m_CameraTransform.position);

            FXMaterial.SetFloat(csky_PropertyIDs.f_SunMiePhaseDepthMultID, m_FogParams.sunMiePhaseDepthMultiplier);
            FXMaterial.SetFloat(csky_PropertyIDs.f_MoonMiePhaseDepthMultID, m_FogParams.moonMieṔhaseDepthMultiplier);

            FXMaterial.SetFloat(csky_PropertyIDs.f_RayleighDepthMultID, m_FogParams.rayleighDepthMultiplier);
            FXMaterial.SetFloat(csky_PropertyIDs.f_BlendTintID, m_FogParams.blendTint);
            FXMaterial.SetFloat(csky_PropertyIDs.f_SmoothTintID, m_FogParams.smoothTint);


            int pass = 0;

            switch (m_FogParams.fogMode)
            {
            case FogMode.Linear:

                pass = 0;
                FXMaterial.SetFloat(csky_PropertyIDs.f_StartDistanceID, m_FogParams.startDistance);
                FXMaterial.SetFloat(csky_PropertyIDs.f_EndDistanceID, m_FogParams.endDistance);

                break;

            case FogMode.Exponential:

                pass = 1;
                float densityExp = m_FogParams.density * 1.4426950408f;
                FXMaterial.SetFloat(csky_PropertyIDs.f_DensityID, densityExp);

                break;

            case FogMode.ExponentialSquared:

                pass = 2;
                float densityExp2 = m_FogParams.density * 1.2011224087f;
                FXMaterial.SetFloat(csky_PropertyIDs.f_DensityID, densityExp2);

                break;
            }
            CustomBlit(source, destination, FXMaterial, pass);
        }