PDA

View Full Version : Can you mipmap a depth texture?



PickleWorld
05-05-2005, 11:23 AM
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?

SirKnight
05-05-2005, 12:15 PM
The FBO extension does talk about mipmaped depth textures so I guess you can!

EDIT: THIS IS WRONG! SORRY!

-SirKnight

Java Cool Dude
05-05-2005, 04:35 PM
Does that mean we can start using FBOs to mipmap our shadow maps?

ZbuffeR
05-05-2005, 04:52 PM
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.

PickleWorld
05-06-2005, 05:06 AM
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/technical/depthbuffer.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?)

SirKnight
05-06-2005, 09:21 AM
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. :D

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

-SirKnight

PickleWorld
05-06-2005, 09:48 AM
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.

dorbie
05-06-2005, 11:09 AM
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.

PickleWorld
05-06-2005, 12:13 PM
"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 :)

jra101
05-06-2005, 12:24 PM
This should work fine (GENERATE_MIPMAPS on depth component textures) on NVIDIA GPUs.