Hi,
I have created a texture to get the depth buffer datas :
glGenTextures(1, &depthTexture);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, texWidth, texHeight, 0,GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, texWidth, texHeight );
When I display the texture on screen it works. But now I would like to get depth datas of the texture in the fragment shader and display them, so i used this :
varying vec2 TexCoord;
uniform sampler2D BaseImageDepth;
void main (void)
{
gl_FragColor = texture2D( BaseImageDepth,TextCoord);
}
But the result is in RGB, I don’t get the depth value. I also try another way but i have exactly the same result (in RGB):
varying vec3 TexCoord;
uniform sampler2DShadow BaseImageDepth;
void main (void)
{
gl_FragColor = shadow2D( BaseImageDepth , TextCoord);
}
So do you know where can be the problem ?
thanks by advance!