Still nothing, it appears to be empty. Could it be possible that I need a renderbuffer in order to render to the depth textures?
Still nothing, it appears to be empty. Could it be possible that I need a renderbuffer in order to render to the depth textures?
No render buffers are just that - buffers. To display depth them you need a texture.
What is the difference betwen your znear and zfar?
1999.99. zNear is 0.01 and zFar is 2000.0
Hi,
I've got the exact same problem except I only use sampler2D as shadow map. I should have read some thread before post mine. However, I'm quite sure the answer to your problem will also solve mine.
Bumping...
Another bump...
You're going to need to dig into this one and provide more info that you find out through debugging.
For starters, do what one of the posters suggested and read back the depth values and print them out. To start with, don't draw any batches -- just read back the values that you're initializing them to with glClear( GL_DEPTH_BUFFER_BIT ). Before calling this, use glClearDepth() to set the depth value that you clear the pixels in the depth buffer to. Then read them back with:
Code :glReadPixels( 0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, buf );
And print out the values. Make sure you're getting the clear value. Try for both 0 and 1 clear values. Then set the clear value to 1 and go render with your shader. Use this to diagnose the readback. Modify your shader incrementally to determine where the bad values are coming from (or establish that you are in-fact getting reasonable values).
I already was able to render the clear depth to the FBO, both 0, 1, and stuff in between, as a quad to the screen that showed up with varying shades of grey.
However, I tried glReadPixels anyways, and get 0 every time. Since the quad rendering works though, I assume I just did not set up glReadPixels properly. I am not even sure how glReadPixels is supposed to work with a cube map anyways.
The shader may be a problem in the future, but right now, no geometry is showing up on the depth buffer at all. I get geometry when using the color textures instead of depth textures though.
I haven't done it, but doesn't seems like there's anything special. glReadPixels reads from the active read buffer of the active READ framebuffer. You've bound a specific face of the cubemap to the framebuffer. So given that you've set the read buffer and read framebuffer properly, it'll read from the texture through that framebuffer.
I accidentally ran it after I unbound the FBO, but now I have it reading the pixels properly. It is just the clear value everywhere, just like when I rendered it as a quad to the screen. So it must be how the scene is being rendered to the depth textures. It can't be the scene Render() function, since it works perfectly with color textures.