From: Brian P. <br...@va...> - 2001-02-20 16:54:30
|
While working on the texture image code I had to fix some things related to color index (paletted) texture images. That got me thinking about other texture formats like depth textures. So, I implemented the GL_SGIX_depth_texture extension and then GL_SGIX_shadow to exercise it. GL_SGIX_shadow_ambient was a simple addition on top of that. Together, these extensions implement shadow maps (invented by Williams, I think). Basically, the scene is first rendered from the point of view of the light source in order to generate a depth map. Then, the scene is rendered from the regular camera's point of view. Texgen and a special texture matrix compute the projection of each vertex (as a texture coordinate) into the light's coordinate system. During texturing, we compare the texture R component to the depth map value at (S,T). The result of the comparison determines whether or not the fragment is shadowed. The technique isn't perfect but can work pretty well in the right situation. There's a demo in Mesa/demos/shadowtex.c My implementation isn't 100% complete either. Right now, the depth texture is only sampled with nearest/nearest filtering and the texels are always stored as floats. I'll try to fix those things in the not-too distant future. -Brian |