Unity3d Unity如何使图像效果着色器与延迟渲染一起工作?

Unity3d Unity如何使图像效果着色器与延迟渲染一起工作?,unity3d,shader,deferred-rendering,Unity3d,Shader,Deferred Rendering,我有一个简单的雾着色器,它可以很好地进行正向渲染。但是,我也需要让它在延迟渲染上工作。我被告知只需更改调用着色器的脚本。 我的fog calling C#脚本: 你能帮我找到我到底需要写些什么才能使延迟渲染工作正常吗?我已经阅读了很多关于这方面的内容,并研究了所有关于着色器的Unity文档,但是没有关于如何将其用于图像效果着色器的示例 using UnityEngine; using UnityEngine.Rendering; [ExecuteInEditMode] [RequireComp

我有一个简单的雾着色器,它可以很好地进行正向渲染。但是,我也需要让它在延迟渲染上工作。我被告知只需更改调用着色器的脚本。 我的fog calling C#脚本:

你能帮我找到我到底需要写些什么才能使延迟渲染工作正常吗?我已经阅读了很多关于这方面的内容,并研究了所有关于着色器的Unity文档,但是没有关于如何将其用于图像效果着色器的示例

using UnityEngine;
using UnityEngine.Rendering;

[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class Fog : MonoBehaviour
{
    public Color fogColor;
    public float minDistance;
    public float maxDistance;

    Shader _shader;
    Material _material;

    static class Uniforms
    {
        internal static readonly int _FogColor = Shader.PropertyToID("_FogColor");
        internal static readonly int _MinMax = Shader.PropertyToID("_MinMax");
    }


    public enum BlendMode { Blend, Additive, Multiplicative};

    public BlendMode blendMode;

    void OnEnable()
    {
        if (_shader == null) {
            _shader = Shader.Find("Hidden/Fog");
        }
        _material = new Material(_shader);
        _material.hideFlags = HideFlags.DontSave;
    }

    void OnDisable()
    {
        DestroyImmediate(_material);
    }

    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        _material.SetColor(Uniforms._FogColor, fogColor);
        _material.SetVector(Uniforms._MinMax, new Vector4(minDistance, maxDistance, 0, 0));
        Graphics.Blit(source, destination, _material, (int)blendMode);
    }
}