- Home /
Using custom RenderTexture in ImageEffects.
Hello dear community!
I'm having trouble wrapping my head around how to best approach this issue, and none of the documentation is very clear on how this is supposed to work (but then again, i'm not exactly a shader pro).
Essentially, I want to render my scene, using a replacement shader, then save that result in a renderTexture and finally, sampling that texture in a postFX shader (tldr; a custom render pass).
Now, i've gotten as far as rendering my scene with the replacement shader, using a secondary camera. And i think i am correctly storing it in a RenderTexture - but here is the issue:
How to use the RenderTexture result in a Image Effect like shader? When is the result of the rendering "ready"? I've gotten to the point where i know it has to do with the OnRenderImage function, but i don't really know how to "pass" the result of my RenderTexture in a way that makes it accessible in my shader.
Cheers and thanks!
Answer by rageingnonsense · Jul 18, 2017 at 07:37 PM
This is super simple. The RenderTexture you create from your camera can be used like any other texture. So, you create a material, select the shader you want to use, and then use the rendertexture as one of the textures.
I am assuming you have a RenderTexture asset you created, that your camera is rendering to. You just need to drag it to your material like you woudl any other texture. You can also do this programmatically I suppose, but the concept is the same.