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);
        }
        public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer cmd   = context.command;
            PropertySheet sheet = context.propertySheets.Get(shader);

            cmd.BeginSample(PROFILER_TAG);

            UpdateNoiseTexture(settings.frequncy, settings.noiseTextureWidth, settings.noiseTextureHeight, settings.stripeLength);

            sheet.properties.SetFloat(ShaderIDs.indensity, settings.intensity);

            if (_noiseTexture != null)
            {
                sheet.properties.SetTexture(ShaderIDs.noiseTex, _noiseTexture);
            }

            if (settings.needStripColorAdjust == true)
            {
                sheet.EnableKeyword("NEED_TRASH_FRAME");
                sheet.properties.SetColor(ShaderIDs.StripColorAdjustColor, settings.StripColorAdjustColor);
                sheet.properties.SetFloat(ShaderIDs.StripColorAdjustIndensity, settings.StripColorAdjustIndensity);
            }
            else
            {
                sheet.DisableKeyword("NEED_TRASH_FRAME");
            }

            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
            cmd.EndSample(PROFILER_TAG);
        }
        public void RenderAfterOpaque(PostProcessRenderContext context)
        {
            var cmd = context.command;

            cmd.BeginSample("Ambient Occlusion");
            SetResources(context.resources);
            PrepareDownsamping(context);
            PreparePropertySheet(context);
            CheckAOTexture(context);

            // In Forward mode, fog is applied at the object level in the grometry pass so we need
            // to apply it to AO as well or it'll drawn on top of the fog effect.
            if (context.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
            {
                m_CompositionPropertySheet.EnableKeyword("APPLY_FORWARD_FOG");
                m_CompositionPropertySheet.properties.SetVector(
                    ShaderIDs.FogParams,
                    new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance)
                    );
            }

            GenerateAOMap(cmd, context.camera, m_AmbientOnlyAO, null, false);
            PushDebug(context);
            cmd.SetGlobalTexture(ShaderIDs.MSVOcclusionTexture, m_AmbientOnlyAO);
            cmd.BlitFullscreenTriangle(context.source, context.destination, m_CompositionPropertySheet, 0);
            cmd.EndSample("Ambient Occlusion");
        }
        public override void Render(PostProcessRenderContext context)
        {
            Texture texture = base.settings.spectralLut.value;

            if (texture == null)
            {
                if (m_InternalSpectralLut == null)
                {
                    m_InternalSpectralLut = new Texture2D(3, 1, TextureFormat.RGB24, mipmap: false)
                    {
                        name       = "Chromatic Aberration Spectrum Lookup",
                        filterMode = FilterMode.Bilinear,
                        wrapMode   = TextureWrapMode.Clamp,
                        anisoLevel = 0,
                        hideFlags  = HideFlags.DontSave
                    };
                    m_InternalSpectralLut.SetPixels(new Color[3]
                    {
                        new Color(1f, 0f, 0f),
                        new Color(0f, 1f, 0f),
                        new Color(0f, 0f, 1f)
                    });
                    m_InternalSpectralLut.Apply();
                }
                texture = m_InternalSpectralLut;
            }
            PropertySheet uberSheet = context.uberSheet;

            uberSheet.EnableKeyword((!base.settings.fastMode) ? "CHROMATIC_ABERRATION" : "CHROMATIC_ABERRATION_LOW");
            uberSheet.properties.SetFloat(ShaderIDs.ChromaticAberration_Amount, (float)base.settings.intensity * 0.05f);
            uberSheet.properties.SetTexture(ShaderIDs.ChromaticAberration_SpectralLut, texture);
        }
Example #6
0
 public static void SetKeyword(this PropertySheet sheet, string prefix, Enum selection)
 {
     foreach (Enum value in Enum.GetValues(selection.GetType()))
     {
         sheet.DisableKeyword(FormatKeyword(prefix, value));
     }
     sheet.EnableKeyword(FormatKeyword(prefix, selection));
 }
Example #7
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet = context.propertySheets.Get(PPoseidonSettings.Instance.UnderwaterShader);

            sheet.properties.SetFloat(PMat.PP_WATER_LEVEL, settings.waterLevel);
            sheet.properties.SetFloat(PMat.PP_MAX_DEPTH, settings.maxDepth);
            sheet.properties.SetFloat(PMat.PP_SURFACE_COLOR_BOOST, settings.surfaceColorBoost);

            sheet.properties.SetColor(PMat.PP_SHALLOW_FOG_COLOR, settings.shallowFogColor);
            sheet.properties.SetColor(PMat.PP_DEEP_FOG_COLOR, settings.deepFogColor);
            sheet.properties.SetFloat(PMat.PP_VIEW_DISTANCE, settings.viewDistance);

            if (settings.enableCaustic && settings.causticTexture.value != null)
            {
                sheet.EnableKeyword(PMat.KW_PP_CAUSTIC);
                sheet.properties.SetTexture(PMat.PP_NOISE_TEX, PPoseidonSettings.Instance.NoiseTexture);
                sheet.properties.SetTexture(PMat.PP_CAUSTIC_TEX, settings.causticTexture.value);
                sheet.properties.SetFloat(PMat.PP_CAUSTIC_SIZE, settings.causticSize);
                sheet.properties.SetFloat(PMat.PP_CAUSTIC_STRENGTH, settings.causticStrength);
            }
            else
            {
                sheet.DisableKeyword(PMat.KW_PP_CAUSTIC);
            }

            if (settings.enableDistortion && settings.distortionNormalMap.value != null)
            {
                sheet.EnableKeyword(PMat.KW_PP_DISTORTION);
                sheet.properties.SetTexture(PMat.PP_DISTORTION_TEX, settings.distortionNormalMap.value);
                sheet.properties.SetFloat(PMat.PP_DISTORTION_STRENGTH, settings.distortionStrength);
                sheet.properties.SetFloat(PMat.PP_WATER_FLOW_SPEED, settings.waterFlowSpeed);
            }
            else
            {
                sheet.DisableKeyword(PMat.KW_PP_DISTORTION);
            }

            sheet.properties.SetVector(PMat.PP_CAMERA_VIEW_DIR, context.camera.transform.forward);
            sheet.properties.SetFloat(PMat.PP_CAMERA_FOV, context.camera.fieldOfView);
            sheet.properties.SetMatrix(PMat.PP_CAMERA_TO_WORLD_MATRIX, context.camera.cameraToWorldMatrix);
            sheet.properties.SetFloat(PMat.PP_INTENSITY, settings.intensity);

            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
        }
Example #8
0
 public static void SetKeyword(this PropertySheet sheet, string keyword, bool value)
 {
     if (value)
     {
         sheet.EnableKeyword(keyword);
     }
     else
     {
         sheet.DisableKeyword(keyword);
     }
 }
Example #9
0
 protected override void SetKeyword(string keyword, bool enabled)
 {
     if (enabled)
     {
         _sheet.EnableKeyword(keyword);
     }
     else
     {
         _sheet.DisableKeyword(keyword);
     }
 }
 private void ParamSwitch(PropertySheet mat, bool paramValue, string paramName)
 {
     if (paramValue)
     {
         mat.EnableKeyword(paramName);
     }
     else
     {
         mat.DisableKeyword(paramName);
     }
 }
Example #11
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);
        }
Example #12
0
        private void RenderExternalPipeline3D(PostProcessRenderContext context)
        {
            Texture value = base.settings.externalLut.value;

            if (!(value == null))
            {
                PropertySheet uberSheet = context.uberSheet;
                uberSheet.EnableKeyword("COLOR_GRADING_HDR_3D");
                uberSheet.properties.SetTexture(ShaderIDs.Lut3D, value);
                uberSheet.properties.SetVector(ShaderIDs.Lut3D_Params, new Vector2(1f / (float)value.width, (float)value.width - 1f));
                uberSheet.properties.SetFloat(ShaderIDs.PostExposure, RuntimeUtilities.Exp2(base.settings.postExposure.value));
                context.logLut = value;
            }
        }
        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");
            }
        }
Example #14
0
    public override void Render(PostProcessRenderContext ctx)
    {
        ResolveCastRendererMethod();

        var cam   = ctx.camera;
        var cmd   = ctx.command;
        var layer = cam.GetComponent <PostProcessLayer>();

        var aoBundle   = layer.GetBundle <AmbientOcclusion>();
        var aoSettings = (AmbientOcclusion)aoBundle.settings;

        if (aoSettings.IsEnabledAndSupported(ctx) && CastRendererMethod != null)
        {
            var aoRenderer = CastRendererMethod.Invoke(aoBundle, null);
            var aoMethod   = GetMethod.Invoke(aoRenderer, new object[0]);

            if (aoMethod.GetType() == MultiScaleVO)
            {
                cmd.BeginSample("Ambient Occlusion");
                SetResourcesMethod.Invoke(aoMethod, new object[] { ctx.resources });
                PreparePropertySheetMethod.Invoke(aoMethod, new object[] { ctx });

                SetResources(ctx.resources);
                PreparePropertySheet(ctx, aoSettings);
                CheckAOTexture(ctx);

                // In Forward mode, fog is applied at the object level in the grometry pass so we need
                // to apply it to AO as well or it'll drawn on top of the fog effect.
                if (ctx.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
                {
                    PropertySheet.EnableKeyword("APPLY_FORWARD_FOG");
                    PropertySheet.properties.SetVector(
                        ShaderIDsFogParams,
                        new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance)
                        );
                }

                GenerateAOMapMethod.Invoke(aoMethod, new object[] { cmd, cam, AmbientOnlyAOIdentifier, null, false, false });
                PushDebug(ctx);
                cmd.SetGlobalTexture(ShaderIDsMSVOcclusionTexture, AmbientOnlyAO);

                cmd.BlitFullscreenTriangle(ctx.source, ctx.destination);

                cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, ctx.destination, PropertySheet, (int)Pass.CompositionForward);
                cmd.EndSample("Ambient Occlusion");
            }
        }
    }
        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);
        }
        void UpdateFrequency(PropertySheet sheet)
        {
            if (settings.intervalType.value == IntervalType.Random)
            {
                randomFrequency = UnityEngine.Random.Range(0, settings.frequency);
            }

            if (settings.intervalType.value == IntervalType.Infinite)
            {
                sheet.EnableKeyword("USING_FREQUENCY_INFINITE");
            }
            else
            {
                sheet.DisableKeyword("USING_FREQUENCY_INFINITE");
            }
        }
Example #17
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet uberSheet = context.uberSheet;

            uberSheet.EnableKeyword("VIGNETTE");
            uberSheet.properties.SetColor(ShaderIDs.Vignette_Color, base.settings.color.value);
            if ((VignetteMode)base.settings.mode == VignetteMode.Classic)
            {
                uberSheet.properties.SetFloat(ShaderIDs.Vignette_Mode, 0f);
                uberSheet.properties.SetVector(ShaderIDs.Vignette_Center, base.settings.center.value);
                float z = (1f - base.settings.roundness.value) * 6f + base.settings.roundness.value;
                uberSheet.properties.SetVector(ShaderIDs.Vignette_Settings, new Vector4(base.settings.intensity.value * 3f, base.settings.smoothness.value * 5f, z, (!base.settings.rounded.value) ? 0f : 1f));
                uberSheet.properties.SetFloat(ShaderIDs.Vignette_Opacity, Mathf.Clamp01(base.settings.opacity.value));
            }
            else
            {
                uberSheet.properties.SetFloat(ShaderIDs.Vignette_Mode, 1f);
                uberSheet.properties.SetTexture(ShaderIDs.Vignette_Mask, base.settings.mask.value);
                uberSheet.properties.SetFloat(ShaderIDs.Vignette_Opacity, Mathf.Clamp01(base.settings.opacity.value));
            }
        }
        void UpdateFrequency(PropertySheet sheet)
        {
            if (settings.intervalType.value == IntervalType.Random)
            {
                if (frameCount > settings.Frequency)
                {
                    frameCount      = 0;
                    randomFrequency = UnityEngine.Random.Range(0, settings.Frequency);
                }
                frameCount++;
            }

            if (settings.intervalType.value == IntervalType.Infinite)
            {
                sheet.EnableKeyword("USING_Frequency_INFINITE");
            }
            else
            {
                sheet.DisableKeyword("USING_Frequency_INFINITE");
            }
        }
        public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer cmd   = context.command;
            PropertySheet sheet = context.propertySheets.Get(shader);

            cmd.BeginSample(PROFILER_TAG);

            UpdateFrequency(sheet);

            if (settings.jitterDirection.value == Direction.Horizontal)
            {
                sheet.EnableKeyword("JITTER_DIRECTION_HORIZONTAL");
            }
            else
            {
                sheet.DisableKeyword("JITTER_DIRECTION_HORIZONTAL");
            }

            sheet.properties.SetVector(ShaderIDs.Params, new Vector4(settings.splittingNumber, settings.amount, settings.speed * 100f,
                                                                     settings.intervalType.value == IntervalType.Random ? randomFrequency : settings.frequency));

            cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, settings.splittingDirection.value == Direction.Horizontal ? 0 : 1);
            cmd.EndSample(PROFILER_TAG);
        }
Example #20
0
        public override void Render(PostProcessRenderContext context)
        {
            float realtimeSinceStartup = Time.realtimeSinceStartup;
            float z = HaltonSeq.Get(m_SampleIndex & 0x3FF, 2);
            float w = HaltonSeq.Get(m_SampleIndex & 0x3FF, 3);

            if (++m_SampleIndex >= 1024)
            {
                m_SampleIndex = 0;
            }
            if (m_GrainLookupRT == null || !m_GrainLookupRT.IsCreated())
            {
                RuntimeUtilities.Destroy(m_GrainLookupRT);
                m_GrainLookupRT = new RenderTexture(128, 128, 0, GetLookupFormat())
                {
                    filterMode = FilterMode.Bilinear,
                    wrapMode   = TextureWrapMode.Repeat,
                    anisoLevel = 0,
                    name       = "Grain Lookup Texture"
                };
                m_GrainLookupRT.Create();
            }
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.grainBaker);

            propertySheet.properties.Clear();
            propertySheet.properties.SetFloat(ShaderIDs.Phase, realtimeSinceStartup % 10f);
            context.command.BeginSample("GrainLookup");
            context.command.BlitFullscreenTriangle(BuiltinRenderTextureType.None, m_GrainLookupRT, propertySheet, base.settings.colored.value ? 1 : 0);
            context.command.EndSample("GrainLookup");
            PropertySheet uberSheet = context.uberSheet;

            uberSheet.EnableKeyword("GRAIN");
            uberSheet.properties.SetTexture(ShaderIDs.GrainTex, m_GrainLookupRT);
            uberSheet.properties.SetVector(ShaderIDs.Grain_Params1, new Vector2(base.settings.lumContrib.value, base.settings.intensity.value * 20f));
            uberSheet.properties.SetVector(ShaderIDs.Grain_Params2, new Vector4((float)context.width / (float)m_GrainLookupRT.width / base.settings.size.value, (float)context.height / (float)m_GrainLookupRT.height / base.settings.size.value, z, w));
        }
Example #21
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);
        }
Example #22
0
        private void RenderHDRPipeline3D(PostProcessRenderContext context)
        {
            CheckInternalLogLut();
            ComputeShader lut3DBaker  = context.resources.computeShaders.lut3DBaker;
            int           kernelIndex = 0;

            switch (base.settings.tonemapper.value)
            {
            case Tonemapper.None:
                kernelIndex = lut3DBaker.FindKernel("KGenLut3D_NoTonemap");
                break;

            case Tonemapper.Neutral:
                kernelIndex = lut3DBaker.FindKernel("KGenLut3D_NeutralTonemap");
                break;

            case Tonemapper.ACES:
                kernelIndex = lut3DBaker.FindKernel("KGenLut3D_AcesTonemap");
                break;

            case Tonemapper.Custom:
                kernelIndex = lut3DBaker.FindKernel("KGenLut3D_CustomTonemap");
                break;
            }
            CommandBuffer command = context.command;

            command.SetComputeTextureParam(lut3DBaker, kernelIndex, "_Output", m_InternalLogLut);
            command.SetComputeVectorParam(lut3DBaker, "_Size", new Vector4(33f, 0.03125f, 0f, 0f));
            Vector3 v = ColorUtilities.ComputeColorBalance(base.settings.temperature.value, base.settings.tint.value);

            command.SetComputeVectorParam(lut3DBaker, "_ColorBalance", v);
            command.SetComputeVectorParam(lut3DBaker, "_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;

            command.SetComputeVectorParam(lut3DBaker, "_HueSatCon", new Vector4(x, y, z, 0f));
            Vector4 a  = new Vector4(base.settings.mixerRedOutRedIn, base.settings.mixerRedOutGreenIn, base.settings.mixerRedOutBlueIn, 0f);
            Vector4 a2 = new Vector4(base.settings.mixerGreenOutRedIn, base.settings.mixerGreenOutGreenIn, base.settings.mixerGreenOutBlueIn, 0f);
            Vector4 a3 = new Vector4(base.settings.mixerBlueOutRedIn, base.settings.mixerBlueOutGreenIn, base.settings.mixerBlueOutBlueIn, 0f);

            command.SetComputeVectorParam(lut3DBaker, "_ChannelMixerRed", a / 100f);
            command.SetComputeVectorParam(lut3DBaker, "_ChannelMixerGreen", a2 / 100f);
            command.SetComputeVectorParam(lut3DBaker, "_ChannelMixerBlue", a3 / 100f);
            Vector3 vector  = ColorUtilities.ColorToLift(base.settings.lift.value * 0.2f);
            Vector3 vector2 = ColorUtilities.ColorToGain(base.settings.gain.value * 0.8f);
            Vector3 vector3 = ColorUtilities.ColorToInverseGamma(base.settings.gamma.value * 0.8f);

            command.SetComputeVectorParam(lut3DBaker, "_Lift", new Vector4(vector.x, vector.y, vector.z, 0f));
            command.SetComputeVectorParam(lut3DBaker, "_InvGamma", new Vector4(vector3.x, vector3.y, vector3.z, 0f));
            command.SetComputeVectorParam(lut3DBaker, "_Gain", new Vector4(vector2.x, vector2.y, vector2.z, 0f));
            command.SetComputeTextureParam(lut3DBaker, kernelIndex, "_Curves", GetCurveTexture(hdr: true));
            if (base.settings.tonemapper.value == Tonemapper.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);
                command.SetComputeVectorParam(lut3DBaker, "_CustomToneCurve", m_HableCurve.uniforms.curve);
                command.SetComputeVectorParam(lut3DBaker, "_ToeSegmentA", m_HableCurve.uniforms.toeSegmentA);
                command.SetComputeVectorParam(lut3DBaker, "_ToeSegmentB", m_HableCurve.uniforms.toeSegmentB);
                command.SetComputeVectorParam(lut3DBaker, "_MidSegmentA", m_HableCurve.uniforms.midSegmentA);
                command.SetComputeVectorParam(lut3DBaker, "_MidSegmentB", m_HableCurve.uniforms.midSegmentB);
                command.SetComputeVectorParam(lut3DBaker, "_ShoSegmentA", m_HableCurve.uniforms.shoSegmentA);
                command.SetComputeVectorParam(lut3DBaker, "_ShoSegmentB", m_HableCurve.uniforms.shoSegmentB);
            }
            context.command.BeginSample("HdrColorGradingLut3D");
            int num = Mathf.CeilToInt(8.25f);

            command.DispatchCompute(lut3DBaker, kernelIndex, num, num, num);
            context.command.EndSample("HdrColorGradingLut3D");
            RenderTexture internalLogLut = m_InternalLogLut;
            PropertySheet uberSheet      = context.uberSheet;

            uberSheet.EnableKeyword("COLOR_GRADING_HDR_3D");
            uberSheet.properties.SetTexture(ShaderIDs.Lut3D, internalLogLut);
            uberSheet.properties.SetVector(ShaderIDs.Lut3D_Params, new Vector2(1f / (float)internalLogLut.width, (float)internalLogLut.width - 1f));
            uberSheet.properties.SetFloat(ShaderIDs.PostExposure, RuntimeUtilities.Exp2(base.settings.postExposure.value));
            context.logLut = internalLogLut;
        }
Example #23
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));
        }
        public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer command = context.command;

            command.BeginSample("BloomPyramid");
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.bloom);

            propertySheet.properties.SetTexture(ShaderIDs.AutoExposureTex, context.autoExposureTexture);
            float num   = Mathf.Clamp(base.settings.anamorphicRatio, -1f, 1f);
            float num2  = (!(num < 0f)) ? 0f : (0f - num);
            float num3  = (!(num > 0f)) ? 0f : num;
            int   num4  = Mathf.FloorToInt((float)context.screenWidth / (2f - num2));
            int   num5  = Mathf.FloorToInt((float)context.screenHeight / (2f - num3));
            int   num6  = Mathf.Max(num4, num5);
            float num7  = Mathf.Log(num6, 2f) + Mathf.Min(base.settings.diffusion.value, 10f) - 10f;
            int   num8  = Mathf.FloorToInt(num7);
            int   num9  = Mathf.Clamp(num8, 1, 16);
            float num10 = 0.5f + num7 - (float)num8;

            propertySheet.properties.SetFloat(ShaderIDs.SampleScale, num10);
            float   num11 = Mathf.GammaToLinearSpace(base.settings.threshold.value);
            float   num12 = num11 * base.settings.softKnee.value + 1E-05f;
            Vector4 value = new Vector4(num11, num11 - num12, num12 * 2f, 0.25f / num12);

            propertySheet.properties.SetVector(ShaderIDs.Threshold, value);
            float x = Mathf.GammaToLinearSpace(base.settings.clamp.value);

            propertySheet.properties.SetVector(ShaderIDs.Params, new Vector4(x, 0f, 0f, 0f));
            int num13 = base.settings.fastMode ? 1 : 0;
            RenderTargetIdentifier source = context.source;

            for (int i = 0; i < num9; i++)
            {
                int down = m_Pyramid[i].down;
                int up   = m_Pyramid[i].up;
                int pass = (i != 0) ? (2 + num13) : num13;
                context.GetScreenSpaceTemporaryRT(command, down, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, num4, num5);
                context.GetScreenSpaceTemporaryRT(command, up, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, num4, num5);
                command.BlitFullscreenTriangle(source, down, propertySheet, pass);
                source = down;
                num4   = Mathf.Max(num4 / 2, 1);
                num5   = Mathf.Max(num5 / 2, 1);
            }
            int num14 = m_Pyramid[num9 - 1].down;

            for (int num15 = num9 - 2; num15 >= 0; num15--)
            {
                int down2 = m_Pyramid[num15].down;
                int up2   = m_Pyramid[num15].up;
                command.SetGlobalTexture(ShaderIDs.BloomTex, down2);
                command.BlitFullscreenTriangle(num14, up2, propertySheet, 4 + num13);
                num14 = up2;
            }
            Color   linear = base.settings.color.value.linear;
            float   num16  = RuntimeUtilities.Exp2(base.settings.intensity.value / 10f) - 1f;
            Vector4 value2 = new Vector4(num10, num16, base.settings.dirtIntensity.value, num9);

            if (context.IsDebugOverlayEnabled(DebugOverlay.BloomThreshold))
            {
                context.PushDebugOverlay(command, context.source, propertySheet, 6);
            }
            else if (context.IsDebugOverlayEnabled(DebugOverlay.BloomBuffer))
            {
                propertySheet.properties.SetVector(ShaderIDs.ColorIntensity, new Vector4(linear.r, linear.g, linear.b, num16));
                context.PushDebugOverlay(command, m_Pyramid[0].up, propertySheet, 7 + num13);
            }
            Texture texture = (!(base.settings.dirtTexture.value == null)) ? base.settings.dirtTexture.value : RuntimeUtilities.blackTexture;
            float   num17   = (float)texture.width / (float)texture.height;
            float   num18   = (float)context.screenWidth / (float)context.screenHeight;
            Vector4 value3  = new Vector4(1f, 1f, 0f, 0f);

            if (num17 > num18)
            {
                value3.x = num18 / num17;
                value3.z = (1f - value3.x) * 0.5f;
            }
            else if (num18 > num17)
            {
                value3.y = num17 / num18;
                value3.w = (1f - value3.y) * 0.5f;
            }
            PropertySheet uberSheet = context.uberSheet;

            if ((bool)base.settings.fastMode)
            {
                uberSheet.EnableKeyword("BLOOM_LOW");
            }
            else
            {
                uberSheet.EnableKeyword("BLOOM");
            }
            uberSheet.properties.SetVector(ShaderIDs.Bloom_DirtTileOffset, value3);
            uberSheet.properties.SetVector(ShaderIDs.Bloom_Settings, value2);
            uberSheet.properties.SetColor(ShaderIDs.Bloom_Color, linear);
            uberSheet.properties.SetTexture(ShaderIDs.Bloom_DirtTex, texture);
            command.SetGlobalTexture(ShaderIDs.BloomTex, num14);
            for (int j = 0; j < num9; j++)
            {
                if (m_Pyramid[j].down != num14)
                {
                    command.ReleaseTemporaryRT(m_Pyramid[j].down);
                }
                if (m_Pyramid[j].up != num14)
                {
                    command.ReleaseTemporaryRT(m_Pyramid[j].up);
                }
            }
            command.EndSample("BloomPyramid");
            context.bloomBufferNameID = num14;
        }
Example #25
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");
    }