PDA

View Full Version : read depth buffer value from sampler2DShadow



Josef Grunig
02-24-2006, 02:58 AM
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,

Jo

Relic
02-24-2006, 04:30 AM
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).

Josef Grunig
03-03-2006, 01:28 AM
So, there is no way to know the shadow depth value if texture has been bound with:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_M ODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_F UNC_ARB,GL_LEQUAL);

Did anybody found out a trick to overcome this limitation?

Relic
03-03-2006, 07:37 AM
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.