In my last post I stated that I was having trouble with rendering to a depth texture. But I believe the following has demonstrated that the render to texture is successful and the issue is I can't read from the texture after the rendering is complete.
I used glReadPixels to check if my depth texture is being cleared. I used the following after calling glClear:
glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
printf("depth value is %f",depth);
The print message outputs whatever clear depth I've set before calling glClear (with the fbo bound as the draw buffer), so I at least now know that the depth texture IS being written to. The problem is I just can't get my shaders to read from it! Here is where the texture is sampled:
float mapSample = (texture( gCascadedShadowMap, TexCoord).x);
FragColor = vec4(mapSample,mapSample,mapSample,1);
I am well aware of the usual faintness of the depth-texture rendering, that's why I'm using glClear() with a depth value of around 0.5. I should be seeing a mid-gray screen when I render, but instead I just see blackness. If I set other textures to gCascadedShadowMap, however, it draws the texture to the screen correctly.
Any help or ideas would be greatly appreciated!
Edited by mv348, 28 July 2013 - 09:49 PM.