PDA

View Full Version : accessing shadow map



trout
03-22-2004, 06:36 PM
Hi,

I was wondering if there is any way that I can access the 2D texture used for comparing the depth in shadow mapping.

please let me know if its possible.
thanks,
-t

Tom Nuydens
03-22-2004, 10:35 PM
You mean get the depth values out without doing a comparison? As long as you don't actually enable the comparison, you can have it output the depth value as luminance or alpha. Using the fixed-function texture environment, however, this means the value will be converted to 8 bits, so you lose a lot of precision. I assume (but haven't verified) that this doesn't happen if you access the texture in a fragment program.

As far as I know there's no way to have the comparison enabled and access the raw depth values simultaneously. If you need to that, you can still do the comparison yourself in a fragment program, though.

-- Tom

trout
03-23-2004, 05:06 AM
Thank you for the reply. I am not really trying to access the depth texture even if it sounded like I did want to do that previously.

I want to be able to access the shadows cast of all the objects in the scene(maybe as a texture). I would like to perform some processing on those shadows. please let me know if you have any ideas.

thank you,
-t

jwatte
03-23-2004, 07:46 AM
Calling GetTexImage with DEPTH_COMPONENT generates an INVALID_ENUM error, so you can't get it out that way.

However, you can call ReadPixels with the depth buffer as target / depth component as format when you initially generate the texture. This is likely to performa poorly on deferred-mode tile-based renderers such as Intel Extreme Graphics or the old Kyro stuff, but otherwise works about as well as you'd expect general buffer read-back to work.

Tom Nuydens
03-23-2004, 08:53 AM
Originally posted by trout:
I want to be able to access the shadows cast of all the objects in the scene(maybe as a texture). I would like to perform some processing on those shadows. please let me know if you have any ideas.You mean you want a view of the scene with nothing except the shadows in it? Just do a rendering pass with the shadow map as your only texture, and no additional shading. You can render that to a texture rectangle (or copy it to one), and then do postprocessing effects on that texture by rendering it back to the framebuffer with a fragment program applied.

I hope I'm not still missing your point...

-- Tom