Read depth buffer value from sampler2DShadow

Hi all,

I’m working on a shader using sampler2DShadow target and making depth comparison with shadow2D function. Everything works well, but now I would like to get also the depth value. I know that I can use sampler2D target with texture2D lookup function, but I would like to continue using the sampler2DShadow target. Is there a way to get depth values with this target?

Can I use both target bound to the same texture?

Thank you,


texture2D() has a sampler2D parameter. No way to use the sampler2DShadow with it.
You can easily bind the same texture to two samplers (texture image units).

So, there is no way to know the shadow depth value if texture has been bound with:


Did anybody found out a trick to overcome this limitation?

Correct, there is no way to get the floating point data from the depth texture on a unit which is configured to return a true/false decision with the r_to_texture comparison mode.

Again, you need to bind the same texture image to two differently configured texture image units and access these as two different samplers inside the shader.
Because TexParameters are texture object state you need to have two different texture objects for that, duplicating the downloaded depth texture data. That’s just how OpenGL is.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.