Search Unity

How to pass PostProcessRenderContext.source to a texture property?

Discussion in 'Image Effects' started by JCO123456, Aug 10, 2019.

  1. JCO123456

    JCO123456

    Joined:
    Jul 14, 2018
    Posts:
    98
    Post-processing V2 Stack

    Type some code:
    Code (CSharp):
    1. public override void Render(PostProcessRenderContext iContext)
    2. {
    3.     var sheet = iContext.propertySheets.Get(shader);
    4.     sheet.properties.SetTexture("_SrcTex", iContext.source);
    5. }
    Get a error message:

    Argument 2: cannot convert from 'UnityEngine.Rendering.RenderTargetIdentifier' to 'UnityEngine.Texture' (CS1503) [Assembly-CSharp]


    It means cannot convert iContext.source to Texture Type.

    With Legacy image effect We can pass source RenderTexture to a Texture property:
    Code (CSharp):
    1. void OnRenderImage(RenderTexture src, RenderTexture dest)
    2. {
    3.     material.SetTexture("_SrcTex", src);
    4. }
    We are using Post-processing V2 Stack currently. Legacy image effect has been deprecated.
    How to pass iContext.source to a texture property?
     
    Last edited: Aug 10, 2019