Search Unity

Render to a RenderTexture and use it in the next pass with the same geometry

Discussion in 'Shaders' started by Deleted User, Jul 9, 2020.

  1. Deleted User

    Deleted User

    Guest

    Hi,

    My scene is simple with just a few Quads, and I want to do two Passes rendering:
    1) first pass render the Quads with a single Texture, in fragment shader, write the texture LOD to renderTarget (renderTexture), call it LodRenderTexture,
    2) 2nd pass render the same Quads, use the mainTexture as previous pass, but also use the LodRenderTexture from the previous pass.

    How can I achieve this in Unity through shader and material? I think Forward rendering is good enough. But I am not sure how to set the renderTexture and use it in shader.

    Thanks
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You can't assign a render texture with a shader. To do this you need to use command buffers both to assign the render texture and to manually render your quads. You can render the second pass using the command buffer as well, or you can the render texture used by the quads' material when they're rendered normally in the scene.