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 |
From: Gareth H. <ga...@va...> - 2001-02-20 17:00:34
|
Brian Paul wrote: > > 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. > > ... > > 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. Great work! I remember talking about this with you at SIGGRAPH last year -- I'm really interested in checking this out. -- Gareth |
From: Brian P. <br...@va...> - 2001-02-20 17:13:53
|
Gareth Hughes wrote: > > Brian Paul wrote: > > > > 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. > > > > ... > > > > 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. > > Great work! I remember talking about this with you at SIGGRAPH last > year -- I'm really interested in checking this out. The code was surprisingly simple after I got the new teximage stuff sorted out. I want to experiment with shadow map sampling. Linear filtering won't necessarily give better results than nearest filtering. Consider the discontinuities along object profiles. I might try taking 4 depth samples, perform 4 R comparisons then use the results of those 4 tests to determine if the fragment is shadowed or not. I'm also curious how mipmapping will work out. -Brian |
From: Allen A. <ak...@po...> - 2001-02-20 19:26:24
|
On Tue, Feb 20, 2001 at 10:22:28AM -0700, Brian Paul wrote: | I want to experiment with shadow map sampling. Linear filtering | won't necessarily give better results than nearest filtering. | Consider the discontinuities along object profiles. I might try | taking 4 depth samples, perform 4 R comparisons then use the | results of those 4 tests to determine if the fragment is shadowed | or not. I'm also curious how mipmapping will work out. If I remember correctly, SGIX_shadow is written so that the depth comparisons happen before the mipmap filtering. So in theory you get a shadow value ranging from 0.0 to 1.0, rather than a hard-edged 0.0-or-1.0, and you avoid misclassifying geometry near edges. It's still possible to get artifacts from depth-value quantization and undersampling, of course. Allen |
From: Stephen J B. <sj...@li...> - 2001-02-20 17:26:50
|
On Wed, 21 Feb 2001, Gareth Hughes wrote: > Brian Paul wrote: > > > > 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. > > > > ... > > > > 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. > > Great work! I remember talking about this with you at SIGGRAPH last > year -- I'm really interested in checking this out. It's not a universal panacea though. The most serious problem is that the resolution with which the polygon is rendered from the perspective of the light source generally differs radically from the resolution it'll appear to be from the perspective of the viewer. Hence, you can get shadows plastered inappropriately on the wrong surfaces - or the shadows may have VERY pixellated or have severe aliasing artifacts. But - having said that - in the right situations it works amazingly well. It's a clever hack. You just have to know when you can and can't use it. ---- Steve Baker (817)619-2657 (Vox/Vox-Mail) L3Com/Link Simulation & Training (817)619-2466 (Fax) Work: sj...@li... http://www.link.com Home: sjb...@ai... http://web2.airmail.net/sjbaker1 |