Example #1
0
    public override void Render(PostProcessRenderContext context)
    {
        if (toneMapShader == null)
        {
            return;
        }

        var cmd = context.command;

        sheet = context.propertySheets.Get(toneMapShader);
        sheet.ClearKeywords();

        if (settings.ToneType.value == ToneType.ACES)
        {
            sheet.EnableKeyword("TONEMAPPING_ACES");
        }
        else if (settings.ToneType.value == ToneType.Neutral)
        {
            sheet.EnableKeyword("TONEMAPPING_NEUTRAL");
        }
        //sheet.properties.SetVector(prop_HSV,
        //    new Vector4(settings._Hue.value, settings._Saturation.value, settings._Value.value));

        cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 1);
    }
Example #2
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet   = context.propertySheets.Get(shader);
            CommandBuffer command = context.command;

            command.BeginSample(Uniforms.Name);
            sheet.ClearKeywords();

            switch (settings.mode.value)
            {
            case EZDistortion.Mode.Screen:
                sheet.properties.SetTexture(Uniforms.Property_DistortionTex, settings.distortionTex.value == null ? EZPostProcessingUtility.grayTexture : settings.distortionTex.value);
                break;

            case EZDistortion.Mode.Layer:
                GetDistortionTexture(context);
                sheet.properties.SetTexture(Uniforms.Property_DistortionTex, distortionTex);
                if (settings.depthTest)
                {
                    sheet.properties.SetTexture(Uniforms.Property_DistortionDepthTex, distortionDepthTex);
                    sheet.EnableKeyword(Uniforms.Keyword_DepthTest_On);
                }
                break;
            }
            sheet.properties.SetVector(Uniforms.Property_DistortionIntensity, settings.intensity);
            command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);

            command.EndSample(Uniforms.Name);
        }
Example #3
0
        private void RenderLDRPipeline2D(PostProcessRenderContext context)
        {
            CheckInternalStripLut();
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.lut2DBaker);

            propertySheet.ClearKeywords();
            propertySheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector4(32f, 0.00048828125f, 0.015625f, 1.032258f));
            Vector3 v = ColorUtilities.ComputeColorBalance(base.settings.temperature.value, base.settings.tint.value);

            propertySheet.properties.SetVector(ShaderIDs.ColorBalance, v);
            propertySheet.properties.SetVector(ShaderIDs.ColorFilter, base.settings.colorFilter.value);
            float x = base.settings.hueShift.value / 360f;
            float y = base.settings.saturation.value / 100f + 1f;
            float z = base.settings.contrast.value / 100f + 1f;

            propertySheet.properties.SetVector(ShaderIDs.HueSatCon, new Vector3(x, y, z));
            Vector3 a  = new Vector3(base.settings.mixerRedOutRedIn, base.settings.mixerRedOutGreenIn, base.settings.mixerRedOutBlueIn);
            Vector3 a2 = new Vector3(base.settings.mixerGreenOutRedIn, base.settings.mixerGreenOutGreenIn, base.settings.mixerGreenOutBlueIn);
            Vector3 a3 = new Vector3(base.settings.mixerBlueOutRedIn, base.settings.mixerBlueOutGreenIn, base.settings.mixerBlueOutBlueIn);

            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerRed, a / 100f);
            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerGreen, a2 / 100f);
            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerBlue, a3 / 100f);
            Vector3 v2 = ColorUtilities.ColorToLift(base.settings.lift.value);
            Vector3 v3 = ColorUtilities.ColorToGain(base.settings.gain.value);
            Vector3 v4 = ColorUtilities.ColorToInverseGamma(base.settings.gamma.value);

            propertySheet.properties.SetVector(ShaderIDs.Lift, v2);
            propertySheet.properties.SetVector(ShaderIDs.InvGamma, v4);
            propertySheet.properties.SetVector(ShaderIDs.Gain, v3);
            propertySheet.properties.SetFloat(ShaderIDs.Brightness, (base.settings.brightness.value + 100f) / 100f);
            propertySheet.properties.SetTexture(ShaderIDs.Curves, GetCurveTexture(hdr: false));
            context.command.BeginSample("LdrColorGradingLut2D");
            Texture value = base.settings.ldrLut.value;

            if (value == null)
            {
                context.command.BlitFullscreenTriangle(BuiltinRenderTextureType.None, m_InternalLdrLut, propertySheet, 0);
            }
            else
            {
                propertySheet.properties.SetVector(ShaderIDs.UserLut2D_Params, new Vector4(1f / (float)value.width, 1f / (float)value.height, (float)value.height - 1f, base.settings.ldrLutContribution));
                context.command.BlitFullscreenTriangle(value, m_InternalLdrLut, propertySheet, 1);
            }
            context.command.EndSample("LdrColorGradingLut2D");
            RenderTexture internalLdrLut = m_InternalLdrLut;
            PropertySheet uberSheet      = context.uberSheet;

            uberSheet.EnableKeyword("COLOR_GRADING_LDR_2D");
            uberSheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector3(1f / (float)internalLdrLut.width, 1f / (float)internalLdrLut.height, (float)internalLdrLut.height - 1f));
            uberSheet.properties.SetTexture(ShaderIDs.Lut2D, internalLdrLut);
        }
        void PreparePropertySheet(PostProcessRenderContext context)
        {
            m_PropertySheet = context.propertySheets.Get(m_Resources.shaders.multiScaleAO);
            m_PropertySheet.ClearKeywords();

            m_CompositionPropertySheet = context.propertySheets.Get(Shader.Find("Hidden/PostProcessing/Custom/MSVO"));
            m_CompositionPropertySheet.properties.SetVector(ShaderIDs.AOColor, Color.white - m_Settings.color.value);
            m_CompositionPropertySheet.ClearKeywords();

            if (m_Settings.UseCustomComposition)
            {
                m_CompositionPropertySheet.EnableKeyword("CUSTOM_COMPOSITION");
            }
        }
        public override void Render(PostProcessRenderContext context)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (ShadowMapCaster.shadowMapRenderTarget == null)
            {
                return;
            }

            if (_shader == null || context == null)
            {
                return;
            }

            PropertySheet propertySheet = context.propertySheets.Get(_shader);
            if (propertySheet == null)
            {
                return;
            }

            propertySheet.ClearKeywords();
            Matrix4x4 projectionMatrix = GL.GetGPUProjectionMatrix(context.camera.projectionMatrix, false);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseProjectionMatrix"), projectionMatrix.inverse);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseViewMatrix"), context.camera.cameraToWorldMatrix);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseViewProjectionMatrix"), Matrix4x4.Inverse(projectionMatrix * context.camera.worldToCameraMatrix));

            if (settings.isBlur.value)
            {
                propertySheet.EnableKeyword("PCF_SHADOW");
            }
            else
            {
                propertySheet.DisableKeyword("PCF_SHADOW");
            }
            propertySheet.properties.SetMatrix("_CustomShadowMapLightSpaceMatrix", ShadowMapCaster.lightSpaceMatrix);
            propertySheet.properties.SetColor("_ShadowColor", settings.shadowColor.value);
            propertySheet.properties.SetFloat("_ShadowStrength", settings.strength.value);
            propertySheet.properties.SetTexture("_CustomShadowMap", ShadowMapCaster.shadowMapRenderTarget);
            propertySheet.properties.SetFloat("_ShadowBias", settings.shadowBias.value);
            propertySheet.properties.SetFloat("_ShadowPCFSpread", settings.shadowPcfSpread.value);
            propertySheet.properties.SetVector("_LightDir", ShadowMapCaster.lightDir);

            context.command.BlitFullscreenTriangle(context.source, context.destination, propertySheet, 0);
        }
Example #6
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet   = context.propertySheets.Get(shader);
            CommandBuffer command = context.command;

            command.BeginSample(Uniforms.Name);
            sheet.ClearKeywords();
            sheet.SetKeyword(Uniforms.Keyword_EdgeMode, settings.edgeMode);
            sheet.SetKeyword(Uniforms.Keyword_BlendMode, settings.blendMode);

            GetGlowTexture(context);
            sheet.properties.SetTexture(Uniforms.Property_GlowDepthTex, glowDepthTexture);

            // Determine the iteration count
            int   width       = glowDepthTexture.width / 2;
            int   height      = glowDepthTexture.height / 2;
            int   size        = Mathf.Max(width, height);
            float logSize     = Mathf.Log(size, 2f) + settings.diffusion - 10f;
            int   logSizeInt  = Mathf.FloorToInt(logSize);
            int   iterations  = Mathf.Clamp(logSizeInt, 1, k_MaxPyramidSize);
            float sampleScale = 0.5f + logSize - logSizeInt;

            sheet.properties.SetFloat(Uniforms.Property_SampleScale, sampleScale);

            for (int i = 0; i < iterations; i++)
            {
                context.GetScreenSpaceTemporaryRT(command, m_Pyramid[i].down, 0, pyramidFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, width, height);
                context.GetScreenSpaceTemporaryRT(command, m_Pyramid[i].up, 0, pyramidFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, width, height);
                width  = Mathf.Max(width / 2, 1);
                height = Mathf.Max(height / 2, 1);
            }

            int lastDown = m_Pyramid[0].down;

            command.BlitFullscreenTriangle(glowDepthTexture, lastDown, sheet, settings.mode.value == EZGlow.Mode.Outer ? (int)Pass.GlowOuter : (int)Pass.GlowInner);
            for (int i = 1; i < iterations; i++)
            {
                int mipDown = m_Pyramid[i].down;
                command.BlitFullscreenTriangle(lastDown, mipDown, sheet, (int)Pass.DownSample);
                lastDown = mipDown;
            }

            int lastUp = m_Pyramid[iterations - 1].down;

            for (int i = iterations - 2; i >= 0; i--)
            {
                int mipDown = m_Pyramid[i].down;
                int mipUp   = m_Pyramid[i].up;
                command.SetGlobalTexture(Uniforms.Property_GlowBloomTex, mipDown);
                command.BlitFullscreenTriangle(lastUp, mipUp, sheet, (int)Pass.UpSample);
                lastUp = mipUp;
            }

            command.SetGlobalTexture(Uniforms.Property_GlowTex, m_Pyramid[0].down);
            command.SetGlobalTexture(Uniforms.Property_GlowBloomTex, lastUp);
            sheet.properties.SetFloat(Uniforms.Property_GlowIntensity, settings.intensity);
            sheet.properties.SetColor(Uniforms.Property_GlowColor, settings.color);
            command.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.Combine);

            for (int i = 0; i < iterations; i++)
            {
                command.ReleaseTemporaryRT(m_Pyramid[i].down);
                command.ReleaseTemporaryRT(m_Pyramid[i].up);
            }

            command.EndSample(Uniforms.Name);
        }
Example #7
0
    public override void Render(PostProcessRenderContext context)
    {
        if (bloomShader == null)
        {
            return;
        }

        var cmd = context.command;

        // cmd.BeginSample("Honkei3Bloom");
        var texFormat = context.sourceFormat;

        sheet = context.propertySheets.Get(bloomShader);
        sheet.ClearKeywords();
        cmd.GetTemporaryRT(rt_320x180, 320, 180, 0, FilterMode.Bilinear, texFormat);
        sheet.properties.SetVector(prop_texelSize, new Vector2(0.00078f, 0.00139f));
        sheet.properties.SetColor(prop_Color, settings._bloomColor.value);
        cmd.BlitFullscreenTriangle(context.source, rt_320x180, sheet, 2); //pass First

        //256
        //copy
        cmd.GetTemporaryRT(rt_256x256, 256, 256, 0, FilterMode.Bilinear, texFormat);
        cmd.GetTemporaryRT(rt_256x256x1, 256, 256, 0, FilterMode.Bilinear, texFormat);
        sheet.properties.SetVector(prop_texelSize, new Vector2(0.00156f, 0.00278f));
        cmd.BlitFullscreenTriangle(rt_320x180, rt_256x256x1, sheet, 2);//pass First
        cmd.ReleaseTemporaryRT(rt_320x180);
        //ScalerThreshold
        sheet.properties.SetFloat(prop_Scaler, settings._Scaler.value);
        sheet.properties.SetFloat(prop_Threshhold, settings._Threshhold.value);
        cmd.BlitFullscreenTriangle(rt_256x256x1, rt_256x256, sheet, 1);//pass ScalerThreshold
        //Scaler
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.5625f, 0.00f));
        cmd.BlitFullscreenTriangle(rt_256x256, rt_256x256x1, sheet, 3); //pass Scaler1
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.00f, 1.00f));
        cmd.BlitFullscreenTriangle(rt_256x256x1, rt_256x256, sheet, 3); //pass Scaler1

        cmd.ReleaseTemporaryRT(rt_256x256x1);
        //res in rt_256x256

        //128
        cmd.GetTemporaryRT(rt_128x128, 128, 128, 0, FilterMode.Bilinear, texFormat);
        cmd.GetTemporaryRT(rt_128x128x1, 128, 128, 0, FilterMode.Bilinear, texFormat);

        cmd.BlitFullscreenTriangle(rt_256x256, rt_128x128, sheet, 0);//pass None

        //scaler
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.5625f, 0.00f));
        cmd.BlitFullscreenTriangle(rt_128x128, rt_128x128x1, sheet, 4); //pass Scaler2
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.00f, 1.00f));
        cmd.BlitFullscreenTriangle(rt_128x128x1, rt_128x128, sheet, 4); //pass Scaler2

        cmd.ReleaseTemporaryRT(rt_128x128x1);
        //res in rt_128x128

        //64
        cmd.GetTemporaryRT(rt_64x64, 64, 64, 0, FilterMode.Bilinear, texFormat);
        cmd.GetTemporaryRT(rt_64x64x1, 64, 64, 0, FilterMode.Bilinear, texFormat);

        cmd.BlitFullscreenTriangle(rt_128x128, rt_64x64, sheet, 0);//pass None

        //scaler
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.5625f, 0.00f));
        cmd.BlitFullscreenTriangle(rt_64x64, rt_64x64x1, sheet, 5); //pass Scaler3
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.00f, 1.00f));
        cmd.BlitFullscreenTriangle(rt_64x64x1, rt_64x64, sheet, 5); //pass Scaler3

        cmd.ReleaseTemporaryRT(rt_64x64x1);
        //res in rt_64x64

        //32
        cmd.GetTemporaryRT(rt_32x32, 32, 32, 0, FilterMode.Bilinear, texFormat);
        cmd.GetTemporaryRT(rt_32x32x1, 32, 32, 0, FilterMode.Bilinear, texFormat);

        cmd.BlitFullscreenTriangle(rt_64x64, rt_32x32, sheet, 0);   //pass None
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.5625f, 0.00f));
        cmd.BlitFullscreenTriangle(rt_32x32, rt_32x32x1, sheet, 6); //pass Scaler4
        sheet.properties.SetVector(prop_Scaler, new Vector2(0.00f, 1.00f));
        cmd.BlitFullscreenTriangle(rt_32x32x1, rt_32x32, sheet, 6); //pass Scaler4

        cmd.ReleaseTemporaryRT(rt_32x32x1);

        sheet.properties.SetVector(prop_Coeff, new Vector4(0.24f, 0.24f, 0.28f, 0.225f));
        cmd.SetGlobalTexture(prop_Tex0, rt_256x256);
        cmd.SetGlobalTexture(prop_Tex1, rt_128x128);
        cmd.SetGlobalTexture(prop_Tex2, rt_64x64);
        cmd.SetGlobalTexture(prop_Tex3, rt_32x32);

        if (settings.ToneType.value == ToneType.ACES)
        {
            sheet.EnableKeyword("TONEMAPPING_ACES");
        }
        else if (settings.ToneType.value == ToneType.Neutral)
        {
            sheet.EnableKeyword("TONEMAPPING_NEUTRAL");
        }
        //sheet.properties.SetVector(prop_HSV,
        //    new Vector4(settings._Hue.value, settings._Saturation.value, settings._Value.value));
        //if (settings._UseACESFile)
        //{
        //    sheet.EnableKeyword("USE_ACESFILM");
        //}

        if (settings._DistortionSwitch == true)
        {
            // 如果开启扭曲,进行扭曲处理,
            cmd.GetTemporaryRT(rt_1920x1080, context.screenWidth, context.screenHeight, 0, FilterMode.Bilinear, texFormat);
            cmd.BlitFullscreenTriangle(context.source, rt_1920x1080, sheet, 7);

            sheet.properties.SetFloat(prop_MoveSpeed, settings._MoveSpeed);
            sheet.properties.SetFloat(prop_MoveForce, settings._MoveForce);
            sheet.properties.SetTexture(prop_NoiseTex, settings._NoiseTex);
            sheet.properties.SetTexture(prop_MaskTex, settings._MaskTex);

            cmd.BlitFullscreenTriangle(rt_1920x1080, context.destination, sheet, 8);
            cmd.ReleaseTemporaryRT(rt_1920x1080);
            settings._DistortionSwitch = false;
        }
        else
        {
            cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 7);
        }



        cmd.ReleaseTemporaryRT(rt_256x256);
        cmd.ReleaseTemporaryRT(rt_128x128);
        cmd.ReleaseTemporaryRT(rt_64x64);
        cmd.ReleaseTemporaryRT(rt_32x32);

        //cmd.EndSample("Honkei3Bloom");
    }
Example #8
0
        private void RenderHDRPipeline2D(PostProcessRenderContext context)
        {
            CheckInternalStripLut();
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.lut2DBaker);

            propertySheet.ClearKeywords();
            propertySheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector4(32f, 0.00048828125f, 0.015625f, 1.032258f));
            Vector3 v = ColorUtilities.ComputeColorBalance(base.settings.temperature.value, base.settings.tint.value);

            propertySheet.properties.SetVector(ShaderIDs.ColorBalance, v);
            propertySheet.properties.SetVector(ShaderIDs.ColorFilter, base.settings.colorFilter.value);
            float x = base.settings.hueShift.value / 360f;
            float y = base.settings.saturation.value / 100f + 1f;
            float z = base.settings.contrast.value / 100f + 1f;

            propertySheet.properties.SetVector(ShaderIDs.HueSatCon, new Vector3(x, y, z));
            Vector3 a  = new Vector3(base.settings.mixerRedOutRedIn, base.settings.mixerRedOutGreenIn, base.settings.mixerRedOutBlueIn);
            Vector3 a2 = new Vector3(base.settings.mixerGreenOutRedIn, base.settings.mixerGreenOutGreenIn, base.settings.mixerGreenOutBlueIn);
            Vector3 a3 = new Vector3(base.settings.mixerBlueOutRedIn, base.settings.mixerBlueOutGreenIn, base.settings.mixerBlueOutBlueIn);

            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerRed, a / 100f);
            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerGreen, a2 / 100f);
            propertySheet.properties.SetVector(ShaderIDs.ChannelMixerBlue, a3 / 100f);
            Vector3 v2 = ColorUtilities.ColorToLift(base.settings.lift.value * 0.2f);
            Vector3 v3 = ColorUtilities.ColorToGain(base.settings.gain.value * 0.8f);
            Vector3 v4 = ColorUtilities.ColorToInverseGamma(base.settings.gamma.value * 0.8f);

            propertySheet.properties.SetVector(ShaderIDs.Lift, v2);
            propertySheet.properties.SetVector(ShaderIDs.InvGamma, v4);
            propertySheet.properties.SetVector(ShaderIDs.Gain, v3);
            propertySheet.properties.SetTexture(ShaderIDs.Curves, GetCurveTexture(hdr: true));
            switch (base.settings.tonemapper.value)
            {
            case Tonemapper.Custom:
                propertySheet.EnableKeyword("TONEMAPPING_CUSTOM");
                m_HableCurve.Init(base.settings.toneCurveToeStrength.value, base.settings.toneCurveToeLength.value, base.settings.toneCurveShoulderStrength.value, base.settings.toneCurveShoulderLength.value, base.settings.toneCurveShoulderAngle.value, base.settings.toneCurveGamma.value);
                propertySheet.properties.SetVector(ShaderIDs.CustomToneCurve, m_HableCurve.uniforms.curve);
                propertySheet.properties.SetVector(ShaderIDs.ToeSegmentA, m_HableCurve.uniforms.toeSegmentA);
                propertySheet.properties.SetVector(ShaderIDs.ToeSegmentB, m_HableCurve.uniforms.toeSegmentB);
                propertySheet.properties.SetVector(ShaderIDs.MidSegmentA, m_HableCurve.uniforms.midSegmentA);
                propertySheet.properties.SetVector(ShaderIDs.MidSegmentB, m_HableCurve.uniforms.midSegmentB);
                propertySheet.properties.SetVector(ShaderIDs.ShoSegmentA, m_HableCurve.uniforms.shoSegmentA);
                propertySheet.properties.SetVector(ShaderIDs.ShoSegmentB, m_HableCurve.uniforms.shoSegmentB);
                break;

            case Tonemapper.ACES:
                propertySheet.EnableKeyword("TONEMAPPING_ACES");
                break;

            case Tonemapper.Neutral:
                propertySheet.EnableKeyword("TONEMAPPING_NEUTRAL");
                break;
            }
            context.command.BeginSample("HdrColorGradingLut2D");
            context.command.BlitFullscreenTriangle(BuiltinRenderTextureType.None, m_InternalLdrLut, propertySheet, 2);
            context.command.EndSample("HdrColorGradingLut2D");
            RenderTexture internalLdrLut = m_InternalLdrLut;
            PropertySheet uberSheet      = context.uberSheet;

            uberSheet.EnableKeyword("COLOR_GRADING_HDR_2D");
            uberSheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector3(1f / (float)internalLdrLut.width, 1f / (float)internalLdrLut.height, (float)internalLdrLut.height - 1f));
            uberSheet.properties.SetTexture(ShaderIDs.Lut2D, internalLdrLut);
            uberSheet.properties.SetFloat(ShaderIDs.PostExposure, RuntimeUtilities.Exp2(base.settings.postExposure.value));
        }
Example #9
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet = null;

            switch (settings.effectType.value)
            {
            case FOG_TYPE.DesktopFogPlusWithSkyHaze:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Desktop Fog Plus With Sky Haze"));
                sheet.properties.SetTexture("_NoiseTex", GetTextureNoise0());
                sheet.properties.SetTexture("_Noise3DTex", GetTextureNoise3D());
                break;

            case FOG_TYPE.DesktopFogPlusOrthogonal:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Desktop Fog Plus Orthogonal"));
                sheet.properties.SetTexture("_Noise3DTex", GetTextureNoise3D());
                break;

            case FOG_TYPE.DesktopFogWithSkyHaze:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Desktop Fog With Sky Haze"));
                sheet.properties.SetTexture("_NoiseTex", GetTextureNoise1());
                sheet.properties.SetTexture("_Noise2Tex", GetTextureNoise0());
                break;

            case FOG_TYPE.MobileFogWithSkyHaze:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Mobile Fog With Sky Haze"));
                sheet.properties.SetTexture("_NoiseTex", GetTextureNoise1());
                break;

            case FOG_TYPE.MobileFogBasic:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Mobile Fog Basic"));
                break;

            case FOG_TYPE.MobileFogOnlyGround:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Mobile Fog Only Ground"));
                sheet.properties.SetTexture("_NoiseTex", GetTextureNoise1());
                break;

            case FOG_TYPE.MobileFogOrthogonal:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Mobile Fog Orthogonal"));
                break;

            case FOG_TYPE.MobileFogSimple:
                sheet = context.propertySheets.Get(Shader.Find("DynamicFog/Image Effect PPS/Mobile Fog Simple"));
                break;

            default:
                Debug.LogError("Effect type not implemented.");
                break;
            }

            sheet.properties.SetVector("_ClipDir", context.camera.transform.forward);
            if (UnityEngine.XR.XRSettings.enabled && UnityEngine.XR.XRSettings.eyeTextureDesc.vrUsage == VRTextureUsage.TwoEyes)
            {
                sheet.properties.SetMatrix("_ClipToWorld", context.camera.cameraToWorldMatrix);
            }
            else
            {
                sheet.properties.SetMatrix("_ClipToWorld", context.camera.cameraToWorldMatrix * context.camera.projectionMatrix.inverse);
            }

            // x = haze, y = speed.value = z = noise, w = alpha
            Vector4 skyData = new Vector4(settings.skyHaze, settings.skySpeed, settings.skyNoiseStrength, settings.skyAlpha);

            sheet.properties.SetVector("_FogSkyData", skyData);

            if (settings.useDirectionalLightAsSun)
            {
                if (sunLight == null)
                {
                    sunLight = FindSun();
                }
                if (sunLight != null)
                {
                    sunDirection = sunLight.transform.forward;
                    if (sunLight != null)
                    {
                        sunColor     = sunLight.color;
                        sunIntensity = sunLight.intensity;
                    }
                }
            }

            float fogIntensity = sunIntensity * Mathf.Clamp01(1.0f - sunDirection.y);

            sheet.properties.SetColor("_FogColor", fogIntensity * settings.color.value * sunColor);
            sheet.properties.SetColor("_FogColor2", fogIntensity * settings.color2.value * sunColor);
            Color sColor = fogIntensity * settings.scatteringColor.value;

            sheet.properties.SetColor("_SunColor", new Vector4(sColor.r, sColor.g, sColor.b, settings.scattering));
            sheet.properties.SetVector("_SunDir", -sunDirection);


            float sp = settings.effectType.value == FOG_TYPE.DesktopFogPlusWithSkyHaze ? settings.speed * 5f : settings.speed;

            sheet.properties.SetVector("_FogSpeed", settings.windDirection.value.normalized * sp);

            Vector4 noiseData = new Vector4(settings.noiseStrength, settings.turbulence, context.camera.farClipPlane * 15.0f / 1000f, settings.noiseScale);

            sheet.properties.SetVector("_FogNoiseData", noiseData);

            Vector4 heightData = new Vector4(settings.height + 0.001f, settings.baselineheight, settings.clipUnderBaseline ? -0.01f : -10000, settings.heightFallOff);

            if (settings.effectType == FOG_TYPE.MobileFogOrthogonal || settings.effectType == FOG_TYPE.DesktopFogPlusOrthogonal)
            {
                heightData.z = settings.maxHeight;
            }
            sheet.properties.SetVector("_FogHeightData", heightData);

            sheet.properties.SetFloat("_FogAlpha", settings.alpha);

            Vector4 distance = new Vector4(settings.distance, settings.distanceFallOff, settings.maxDistance, settings.maxDistanceFallOff);

            if (settings.effectType.value.isPlus())
            {
                distance.x  = context.camera.farClipPlane * settings.distance;
                distance.y  = settings.distanceFallOff.value * distance.x + 0.0001f;
                distance.z *= context.camera.farClipPlane;
            }
            sheet.properties.SetVector("_FogDistance", distance);

            sheet.ClearKeywords();

            if (settings.fogOfWarEnabled)
            {
                if (DynamicFogPPS.fogOfWarTexture == null)
                {
                    settings.UpdateFogOfWarTexture();
                }
                Vector3 fogOfWarCenter = settings.fogOfWarCenter;
                Vector3 fogOfWarSize   = settings.fogOfWarSize;
                sheet.properties.SetTexture("_FogOfWar", DynamicFogPPS.fogOfWarTexture);
                sheet.properties.SetVector("_FogOfWarCenter", fogOfWarCenter);
                sheet.properties.SetVector("_FogOfWarSize", fogOfWarSize);
                Vector3 ca = fogOfWarCenter - 0.5f * fogOfWarSize;
                sheet.properties.SetVector("_FogOfWarCenterAdjusted", new Vector3(ca.x / fogOfWarSize.x, 1f, ca.z / fogOfWarSize.z));
                sheet.EnableKeyword("FOG_OF_WAR_ON");
            }
            if (settings.enableDithering)
            {
                sheet.properties.SetFloat("_FogDither", settings.ditherStrength);
                sheet.EnableKeyword("DITHER_ON");
            }
            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
        }