Search Unity

Camera.RenderWithShader + Post Processing Stack V2

Discussion in 'General Graphics' started by gregoired, May 16, 2021.

  1. gregoired

    gregoired

    Joined:
    Apr 8, 2013
    Posts:
    20
    Hey everyone !
    I'd like to improve an old image effect, using Post Processing Stack V2
    Here's my old implementation :
    Code (CSharp):
    1. var temp = cam.targetTexture = RenderTexture.GetTemporary(cam.pixelWidth, cam.pixelHeight,24,RenderTextureFormat.ARGB32);
    2. cam.targetTexture.Create ();
    3. cam.RenderWithShader (shader,"");
    And the new code :

    Code (CSharp):
    1. public override void Render(PostProcessRenderContext context)
    2.         {
    3.  
    4.             ...
    5.             // Can I create a custom render pass in here ?
    6.             context.GetScreenSpaceTemporaryRT(cmd, rt1, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear);
    7.             cmd.BlitFullscreenTriangle(context.source, rt1, sheet, 0);
    8.  
    9.            ...
    10.         }
    it basically create a temporary cam, which is not ideal. I'd like to find a way to make my custom pass by rendering my objects with a shader, then passing that to my image effect shader.