예제 #1
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (this.silentError)
        {
            Graphics.Blit(source, destination);
            return;
        }
        this.BlendAmount = Mathf.Clamp01(this.BlendAmount);
        if (this.colorSpace != QualitySettings.activeColorSpace || this.qualityLevel != this.QualityLevel)
        {
            this.CreateMaterials();
        }
        this.UpdatePostEffectParams();
        bool     flag            = AmplifyColorBase.ValidateLutDimensions(this.LutTexture);
        bool     flag2           = AmplifyColorBase.ValidateLutDimensions(this.LutBlendTexture);
        bool     flag3           = this.LutTexture == null && this.LutBlendTexture == null && this.volumesLutBlendTexture == null;
        Texture  texture         = (this.LutTexture == null) ? this.defaultLut : this.LutTexture;
        Texture  lutBlendTexture = this.LutBlendTexture;
        int      pass            = this.ComputeShaderPass();
        bool     flag4           = this.BlendAmount != 0f || this.blending;
        bool     flag5           = flag4 || (flag4 && lutBlendTexture != null);
        bool     flag6           = flag5;
        bool     flag7           = !flag || !flag2 || flag3;
        Material material;

        if (flag7)
        {
            material = this.materialProcessOnly;
        }
        else if (flag5 || this.volumesBlending)
        {
            if (this.UseDepthMask)
            {
                material = this.materialDepthMaskBlend;
            }
            else
            {
                material = ((this.MaskTexture != null) ? this.materialMaskBlend : this.materialBlend);
            }
        }
        else if (this.UseDepthMask)
        {
            material = this.materialDepthMask;
        }
        else
        {
            material = ((this.MaskTexture != null) ? this.materialMask : this.materialBase);
        }
        material.SetFloat("_Exposure", this.Exposure);
        material.SetFloat("_ShoulderStrength", 0.22f);
        material.SetFloat("_LinearStrength", 0.3f);
        material.SetFloat("_LinearAngle", 0.1f);
        material.SetFloat("_ToeStrength", 0.2f);
        material.SetFloat("_ToeNumerator", 0.01f);
        material.SetFloat("_ToeDenominator", 0.3f);
        material.SetFloat("_LinearWhite", this.LinearWhitePoint);
        material.SetFloat("_LerpAmount", this.BlendAmount);
        if (this.MaskTexture != null)
        {
            material.SetTexture("_MaskTex", this.MaskTexture);
        }
        if (this.UseDepthMask)
        {
            material.SetTexture("_DepthCurveLut", this.depthCurveLut);
        }
        if (!flag7)
        {
            if (this.volumesBlending)
            {
                this.volumesBlendAmount = Mathf.Clamp01(this.volumesBlendAmount);
                this.materialBlendCache.SetFloat("_LerpAmount", this.volumesBlendAmount);
                if (this.blendingFromMidBlend)
                {
                    this.materialBlendCache.SetTexture("_RgbTex", this.midBlendLUT);
                }
                else
                {
                    this.materialBlendCache.SetTexture("_RgbTex", texture);
                }
                this.materialBlendCache.SetTexture("_LerpRgbTex", (this.volumesLutBlendTexture != null) ? this.volumesLutBlendTexture : this.defaultLut);
                Graphics.Blit(texture, this.blendCacheLut, this.materialBlendCache);
            }
            if (flag6)
            {
                this.materialBlendCache.SetFloat("_LerpAmount", this.BlendAmount);
                RenderTexture renderTexture = null;
                if (this.volumesBlending)
                {
                    renderTexture = RenderTexture.GetTemporary(this.blendCacheLut.width, this.blendCacheLut.height, this.blendCacheLut.depth, this.blendCacheLut.format, RenderTextureReadWrite.Linear);
                    Graphics.Blit(this.blendCacheLut, renderTexture);
                    this.materialBlendCache.SetTexture("_RgbTex", renderTexture);
                }
                else
                {
                    this.materialBlendCache.SetTexture("_RgbTex", texture);
                }
                this.materialBlendCache.SetTexture("_LerpRgbTex", (lutBlendTexture != null) ? lutBlendTexture : this.defaultLut);
                Graphics.Blit(texture, this.blendCacheLut, this.materialBlendCache);
                if (renderTexture != null)
                {
                    RenderTexture.ReleaseTemporary(renderTexture);
                }
                material.SetTexture("_RgbBlendCacheTex", this.blendCacheLut);
            }
            else if (this.volumesBlending)
            {
                material.SetTexture("_RgbBlendCacheTex", this.blendCacheLut);
            }
            else
            {
                if (texture != null)
                {
                    material.SetTexture("_RgbTex", texture);
                }
                if (lutBlendTexture != null)
                {
                    material.SetTexture("_LerpRgbTex", lutBlendTexture);
                }
            }
        }
        Graphics.Blit(source, destination, material, pass);
        if (flag6 || this.volumesBlending)
        {
            this.blendCacheLut.DiscardContents();
        }
    }
예제 #2
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        this.BlendAmount = Mathf.Clamp01(this.BlendAmount);
        if (this.colorSpace != QualitySettings.activeColorSpace || this.qualityLevel != this.QualityLevel)
        {
            this.CreateMaterials();
        }
        bool flag  = AmplifyColorBase.ValidateLutDimensions(this.LutTexture);
        bool flag2 = AmplifyColorBase.ValidateLutDimensions(this.LutBlendTexture);
        bool flag3 = this.LutTexture == null && this.LutBlendTexture == null && this.volumesLutBlendTexture == null;

        if (!flag || !flag2 || flag3)
        {
            Graphics.Blit(source, destination);
            return;
        }
        Texture  texture         = (!(this.LutTexture == null)) ? this.LutTexture : this.defaultLut;
        Texture  lutBlendTexture = this.LutBlendTexture;
        int      pass            = base.GetComponent <Camera>().hdr ? 1 : 0;
        bool     flag4           = this.BlendAmount != 0f || this.blending;
        bool     flag5           = flag4 || (flag4 && lutBlendTexture != null);
        bool     flag6           = flag5;
        Material material;

        if (flag5 || this.volumesBlending)
        {
            if (this.MaskTexture != null)
            {
                material = this.materialBlendMask;
            }
            else
            {
                material = this.materialBlend;
            }
        }
        else if (this.MaskTexture != null)
        {
            material = this.materialMask;
        }
        else
        {
            material = this.materialBase;
        }
        material.SetFloat("_lerpAmount", this.BlendAmount);
        if (this.MaskTexture != null)
        {
            material.SetTexture("_MaskTex", this.MaskTexture);
        }
        if (this.volumesBlending)
        {
            this.volumesBlendAmount = Mathf.Clamp01(this.volumesBlendAmount);
            this.materialBlendCache.SetFloat("_lerpAmount", this.volumesBlendAmount);
            if (this.blendingFromMidBlend)
            {
                this.materialBlendCache.SetTexture("_RgbTex", this.midBlendLUT);
            }
            else
            {
                this.materialBlendCache.SetTexture("_RgbTex", texture);
            }
            this.materialBlendCache.SetTexture("_LerpRgbTex", (!(this.volumesLutBlendTexture != null)) ? this.defaultLut : this.volumesLutBlendTexture);
            Graphics.Blit(texture, this.blendCacheLut, this.materialBlendCache);
        }
        if (flag6)
        {
            this.materialBlendCache.SetFloat("_lerpAmount", this.BlendAmount);
            RenderTexture renderTexture = null;
            if (this.volumesBlending)
            {
                renderTexture = RenderTexture.GetTemporary(this.blendCacheLut.width, this.blendCacheLut.height, this.blendCacheLut.depth, this.blendCacheLut.format, RenderTextureReadWrite.Linear);
                Graphics.Blit(this.blendCacheLut, renderTexture);
                this.materialBlendCache.SetTexture("_RgbTex", renderTexture);
            }
            else
            {
                this.materialBlendCache.SetTexture("_RgbTex", texture);
            }
            this.materialBlendCache.SetTexture("_LerpRgbTex", (!(lutBlendTexture != null)) ? this.defaultLut : lutBlendTexture);
            Graphics.Blit(texture, this.blendCacheLut, this.materialBlendCache);
            if (renderTexture != null)
            {
                RenderTexture.ReleaseTemporary(renderTexture);
            }
            material.SetTexture("_RgbBlendCacheTex", this.blendCacheLut);
        }
        else if (this.volumesBlending)
        {
            material.SetTexture("_RgbBlendCacheTex", this.blendCacheLut);
        }
        else
        {
            if (texture != null)
            {
                material.SetTexture("_RgbTex", texture);
            }
            if (lutBlendTexture != null)
            {
                material.SetTexture("_LerpRgbTex", lutBlendTexture);
            }
        }
        Graphics.Blit(source, destination, material, pass);
        if (flag6 || this.volumesBlending)
        {
            this.blendCacheLut.DiscardContents();
        }
    }