- Home /
Best way to access RenderTexture immediately after camera render
I'm creating an effect where I accumulate the output of several cameras to a RenderTexture and then write that to the screen.
What is the best way to access the contents of a RenderTexture after a camera has written to it?
When OnPostRender is called, the target texture has not been written yet. OnRenderImage doesn't seem like the appropriate place, since it sits in the middle of the pipe and I want to access my render texture after one camera has completed and before the next camera begins.
I considered creating a command buffer for CameraEvent.AfterEverything but the documentation says CommandBuffer.Blit works the same as Graphics.Blit and Graphics.Blit won't let me access the depth part of my RenderTexture in my custom shader. The documentation instead tells you to use GL.Begin.
I could try writing the CommandBuffer anyway and instead of blitting, draw geometry and hope that it gives me access to the depth component that way.
Another alternative could be to add an extra camera that doesn't render anything and then access the texture of the previous camera in the next camera's OnPreRender.
Which method would be considered most correct? Thanks for your help!
P.S. I'm simplifying the problem description for brevity. This is all part of an attempt to use early z-test rejection for masking.
Your answer
Follow this Question
Related Questions
Displaying a RenderTexture overlayed ontop of another Camera 0 Answers
How to call Camera.Render from Update 1 Answer
Object shown on top of another, rendering priorities? 2 Answers
ClearFlags don't seem to work when I manually call Render() on my cameras. 0 Answers
OnpostRender is not called 4 Answers