PDA

View Full Version : Shadow mapping with OGL 1.1



Catman
01-27-2004, 10:45 AM
Hello! I'm trying to implement different shadowing technics with OGL 1.1, but I can't find a tutorial/paper about shadow mapping. All tutorials use register combiners and such things. Can someone give me a link to a tutorial that explains shadow mapping using only ogl 1.1 functionality? And btw is this possible?

jwatte
01-27-2004, 11:29 AM
OpenGL 1.1 does not expose or require the shadow mapping texturing modes, nor the render-to-texture necessary to generate those textures.

It does, however, expose enough stencil functionality to implement stencil shadows.

Catman
01-27-2004, 11:46 AM
Thanks. I've already implemented stencil shadows.

So shadow mapping is not possible with ogl 1.1...

flo
01-27-2004, 11:41 PM
With OpenGL 1.1 and no extensions, shadow mapping is indeed difficult (impossible). But if at least multi-texturing and the tex-env-combine extension is supported, depth values can be stored in the alpha channel and used for shadow calculation. Search for the PhD thesis from Wolfgang Heidrich for a more detailed explication.

I think even with single texturing, this can be implemented iff subtractive blending is supported.

Render-to-texture is not really required to create a shadow map.

roffe
01-28-2004, 12:04 AM
Originally posted by flo:
if at least multi-texturing and the tex-env-combine extension is supported, depth values can be stored in the alpha channel and used for shadow calculation.

With gl1.1 and no extensions that would mean regular 8bit/channel textures, so you would have 8bit depth buffer values for compairison. It would be interesting to see how that would look like.

Catman
01-28-2004, 01:01 AM
I've got a lot of paper about shadow mapping with extensions, but I wanted to do it specifically without extension. But thanks anyway.

nrg
01-28-2004, 02:56 AM
Originally posted by jwatte:
OpenGL 1.1 does not expose or require the shadow mapping texturing modes, nor the render-to-texture necessary to generate those textures.


render-to-texture is possible with OGL 1.1 using glCopyTexImage2D().

flo
01-28-2004, 11:29 AM
@roffe: without a doubt, accuracy is an issue with only 8 bit depth resolution.

@Catman: Thinking about it again, I suppose shadow mapping could be even implemented with OpenGL 1.1 without extensions. The main problem is how to simulate the subtraction which is required for shadow calculation. OpenGL supports additive blending, so one could invert one alpha-depth ramp and get a valid subtraction. For example:

Shadow map S: contains depths in [0, 0.5]
Comparing alpha values A: for the same geometric region, dephts range in [0.5, 0].

Now applying the shadow map first results in a alpha value of S.a at a fragment. Then we blend the comparing alpha values with additive blending.
If a fragment is lit, A.a == 0.5 - S.a, that means the new pixels alpha value is 0.5.
If a fragment is not in light, A.a > 0.5 - S.a, that means the new pixels alpha value is greater than 0.5.
So the alpha buffer can again be used as texture, applied again to the frame buffer as screen-aligned quad, and if alpha is less-equal 0.5, a pixel is lit, else not.

JustHanging
01-28-2004, 12:39 PM
Good point, flo.

It's clear, however, that it's extremely unpractical, slow and in most cases bad quality, so better stick with stencil shadows unless it's for some reason out of the question.

8 bit shadow mapping is ok if you have a small scene or low-radius lightsources. It requires at least linear lightspace depth buffer to work, though.

-Ilkka

elevator
01-28-2004, 02:12 PM
Originally posted by Catman:
Hello! I'm trying to implement different shadowing technics with OGL 1.1, but I can't find a tutorial/paper about shadow mapping. All tutorials use register combiners and such things. Can someone give me a link to a tutorial that explains shadow mapping using only ogl 1.1 functionality? And btw is this possible?

It's possible to perform shadow mapping without extensions. You can use dual shadow mapping approach. You generate shadow map and create a range map that maps R texture coordinate. The range map is a 1D texture that map the depth range along z, in this way you overcome the problem of not having the possibility of using directly ARB_shadow, ARB_depth_texture extensions.
The Depth comparison in the case of dual shadow mapping is realized with additive signed alpha with glTexEnv, using two texture stages: One for the depth map and another for the range map.

For further detail about Dual Shadow Mapping approach (no extensions) and hardware shadow mapping with extensions can be found at developer.nvidia.com/attach/1841 in powerpoint format.

Good luck !

jwatte
01-28-2004, 06:29 PM
The alpha trick is clever!



render-to-texture is possible with OGL 1.1 using glCopyTexImage2D()


With the original suggestion, I intended to imply that the depth texture map format isn't available, so you can't copy your depth buffer into the shadow map. Sorry if I confused anyone.

Catman
02-01-2004, 09:25 AM
Thanks for all the ideas. Maybe I'll try elevator's approach...

bakery2k
02-01-2004, 01:17 PM
Originally posted by elevator:
It's possible to perform shadow mapping without extensions...
...using two texture stages...

So the multitexture extension is required? I have implemented shadow mapping using this method (with multitexture), but have not found a way to do it using no extensions (to GL 1.1) at all.

elevator
02-02-2004, 02:00 PM
Originally posted by bakery2k:
So the multitexture extension is required? I have implemented shadow mapping using this method (with multitexture), but have not found a way to do it using no extensions (to GL 1.1) at all.


Multitexture Extension is supported by all the hardware by long time (geforce1,geforce2 ecc), so the problem concerning this doesn't exist http://www.opengl.org/discussion_boards/ubb/smile.gif! So the solution to perform dual shadow mapping exists without multitexturing extension too, you can do multipass rendering, yes it's slow, but this is the way to go http://www.opengl.org/discussion_boards/ubb/smile.gif.

Bye !