Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: Can you mipmap a depth texture?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    122

    Can you mipmap a depth texture?

    I know the depth buffer is non-linear and thus taking a linear combination of the values stored in it does not really make mathematical sense. However, graphics is 99% hack anyway.

    So, given the proper calls, will OpenGl perform mipmap'ing on a depth texture?

    I don't mean using gluBuildMipMaps(). I mean by setting up 3-4 inital depth maps (using glCopyTexImage2D, proper sizes for each lvl, and a GL_TEXTURE_MAX_LEVEL call) and then counting on GL_GENERATE_MIPMAPS to recalculate the maps each pass when I copy the depth information to the 0th lvl texture (so I never have to rip information to main memory from the card to recalculate the mipmaps).

    So basically I guess I am asking does GL_GENERATE_MIPMAPS work with depth textures?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,537

    Re: Can you mipmap a depth texture?

    The FBO extension does talk about mipmaped depth textures so I guess you can!

    EDIT: THIS IS WRONG! SORRY!

    -SirKnight
    -SirKnight

  3. #3
    Junior Member Regular Contributor
    Join Date
    Feb 2004
    Location
    Los Angeles, CA
    Posts
    154

    Re: Can you mipmap a depth texture?

    Does that mean we can start using FBOs to mipmap our shadow maps?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Can you mipmap a depth texture?

    Please correct me if I am wrong, but what can be the use of mipmapped depth map ?
    I mean, averaging depths will not provide soft shadow, only low res improper shadow.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    122

    Re: Can you mipmap a depth texture?

    I am not doing shadows but if I were I would not choose to use a mipmap'ed depth texture. See the depth buffer FAQ (http://www.opengl.org/resources/faq/...epthbuffer.htm) and read section 12.050. It is clear that due to the non-linear nature of the depth texture (and it can be extreme given certain zNear and zFar) that using a mipmap'ed depth texture for shadows would not work.

    However as I said, I am not doing shadows and would still like a mipmap'ed depth texture.

    SirKnight I can not find anywhere in the FBO extension where it talks about mipmap'ing depth textures? There is a section of example code using depth textures and mipmaping but it is mipmap'ing color textures not the depth texture. Where exactly did you see it? (can you cut and paste or provide a section number?)

  6. #6
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,537

    Re: Can you mipmap a depth texture?

    Oooook don't I feel like a moron. I actually read that in the GL_EXT_render_target spec NOT FBO. I had both specs open and was thinking about FBOs for something and for some reason I made that dumb mistake. Sorry.

    But anyway, I still can't think of where mipmaps of a depth texture would do any good.

    -SirKnight
    -SirKnight

  7. #7
    Junior Member Regular Contributor
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    122

    Re: Can you mipmap a depth texture?

    Hey you are right, GL_EXT_render_target does talk about mip-mapped depth textures. It doesn't really tell me anything about the specifics but at least I know it can be done. Thanks.

  8. #8
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Can you mipmap a depth texture?

    MIP mapping is a bad idea.
    The fundamental principal of percentage closer filtering is that filtering is post depth-eye test. MIP mapping will only defeat the algorithm around areas like silhouettes.

    P.S. I suppose you could use MIP maps but the only right way to generate them is to render reduced resolution images. Filtering cannot give you the correct new depth value at the novel pixel centers produced in a 2:1 downsize.

  9. #9
    Junior Member Regular Contributor
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    122

    Re: Can you mipmap a depth texture?

    "Filtering cannot give you the correct new depth value"

    Never said I needed the "correct" value.

    Due to NDA yadda yadda yadda I can not discuss what I am working on so I will just say that while mathematically incorrect a mipmapped depth texture *might* still be useful... I will have to try it out to be sure.

    Where is the fun in only using the hardware in the way it was intended

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    591

    Re: Can you mipmap a depth texture?

    This should work fine (GENERATE_MIPMAPS on depth component textures) on NVIDIA GPUs.

Posting Permissions

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