In a shader, is there a way either to write a custom value to the associated depth-texture (that is, as specified via “depthtex” in a call to “renderSceneInto”), or to retrieve the depth-value of the current fragment?
To explain, I’m working on a post-process effect. The shader for this effect relies primarily on a comparison of depth-values. However, I also want it to take into account some additional data that I intend to render.
In its most basic form, this isn’t all that difficult: I associate a texture with “auxtex” in my call to “renderSceneInto”, render the additional data into “color2”, bind the resultant texture to my final scene-quad, and then read a pixel from the texture.
However, the post-process effect in question already involves reading multiple depth-values, and I find myself wanting to likewise access multiple points in my additional data.
But I’m hesitant to employ too many pixel-reads. And conversely, it seems to me that the depth-texture only really needs a single colour-channel. As a result, I’m hoping to combine the additional data with the depth-data in a single texture. That way my depth-reads would inherently provide my additional data, meaning that there would be no increase in the number of pixel-reads involved.
However, I’m not sure of how to go about this–or whether it’s at all feasible. Hence my question here!