Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Omnidirectional Shadow Maps

  1. #11
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    Still nothing, it appears to be empty. Could it be possible that I need a renderbuffer in order to render to the depth textures?

  2. #12
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171
    No render buffers are just that - buffers. To display depth them you need a texture.
    What is the difference betwen your znear and zfar?

  3. #13
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    1999.99. zNear is 0.01 and zFar is 2000.0

  4. #14
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    11
    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.

  5. #15
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    Bumping...

  6. #16
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    Another bump...

  7. #17
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    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).

  8. #18
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    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.

  9. #19
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    Quote Originally Posted by cireneikual View Post
    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.
    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.

  10. #20
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    114
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •