I'm attempting to set up a depth cube map for omnidirectional shadow mapping, but I've run into issues - specifically, I can't write to depth textures; however, using a renderbuffer in the same place works (I know this because I am currently using a depth renderbuffer in my FBO, and when I change it to a depth texture nothing is ever written). This includes both writing via the fragment shader AND a simple glClear() call - so the problem is also not that I'm just drawing my geometry wrong. Additionally, I have made sure to call glDepthMask( GL_TRUE ).
Here is a short section of code which exhibits the issue for me (FBO creation code left out, but I've used that extensively and it works):
[source lang="cpp"]int texID;// generate depth textureglGenTextures(1,&texID);glBindTexture(GL_TEXTURE_2D,texID);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,32,32,0,GL_DEPTH_COMPONENT,GL_FLOAT,NULL);// attach it to the framebufferglFramebufferTexture(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,texID,0);// check status - returns GL_FRAMEBUFFER_COMPLETELog::info() << glCheckFramebufferStatus();// set the clear depth to 0.5 - should produce grayglClearDepth(0.5f);// clear the depth buffer - this does not work!!glClear(GL_DEPTH_BUFFER_BIT);// bind the depth texture so that glIntercept will write it to diskglBindTexture(GL_TEXTURE_2D,texID);[/source]
However, instead of producing a texture filled with 0.5 depth (would appear gray), it's filled with mostly black and a bit of garbage scattered around the edges.
I've looked at tutorials and I can't seem to find anything I'm doing differently. The example above is pretty much as simple as I could get it. I've also tried different versions of glFramebufferTexture, such as glFramebufferTexture2D, but that didn't make a difference.
My card is ATI HD Radeon 5870 and I have Catalyst 12.8 (ver. 2012.0806.1213.19931).
Edited by Gumgo, 22 October 2012 - 01:01 PM.