- Home /
Using rendertextures in multiple shader passes
Right, so I'm working off some somewhat old (wait, I just checked, 2004? When did 2004 books written in 2004 become old?) book about shaders, and it talks about 'render targets', which are textures that a shader writes to instead of the camera. Which you then use to do...stuff...before you calculate your final output. So basically, that's a RenderTexture, right?
But now I'm trying to make a shader that does something like this
Pass {
//make rendertexture A
}
Pass {
//make rendertexture B
}
Pass {
//final output is something like B-A
}
Is it possible to do something like that? If so, how? I've mentioned it on this forum before, but I am kind of bad at shaders. (Trying to get better!)
VERY interested in the answer to this question. Have you figured anything out?
Sadly, no, I haven't (I haven't really looked at this in a while - in the end I didn't really need this and I moved on to trying other things).
I use Graphics.Blit for that which allows to select which pass to get the shader to render onto the RenderTexture. But I am currently looking for a solution to your same problem: how to reuse the RenderTextures in the shader. It seemed trivial to me to reupload and make a lerp in a fragment shader but I am having unexpected results. In my case I am trying to smooth a movement in GPU; with this goal in $$anonymous$$d, before I do the pass, I upload the RenderTexture that holds the results of the previous Update to the shader and lerp in the pass using the old value. I also tried to keep two separate RenderTextures by calling Graphics.Blit twice with the same pass so I have a copy with the same values and pass one of the two but NO LUC$$anonymous$$ so far. I guess I am missing something in the sequence. RenderTexture doesn't seem to hold the values like I expect. Hope someone comes to point some light at this.