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

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

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.