Multiple shadow casters in shadow mapping.

Started by
5 comments, last by RocketTree 18 years ago
Hi, I have just put together a basic shadow mapping program, mostly cut and pasted together from other tutorials so I can get a better understanding and generally fiddle with things. I am trying to add multiple shadow casters and lights to the scene now and so far my approach is Render depth map for light 1 Render depth map for light 2 Clear out depth and colour buffers Render scene with 2 dim lights to create ambient light Project first depth map and apply bright light Project second depth map and apply different coloured bright light The problem is that the shadows from the first light are only visible inside the shadows from the second light. I am using regular openGL, no shaders here. Is there a way to project multiple shadows at once, or a way of not letting the second light completly overlap the first set of shadows. Thanks
Advertisement
Just in case anyone else gets this problem,

glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
glEnable(GL_BLEND);

on the last 2 passes and remember to turn it off on the first passes
You actually want additive blending for the last 2 passes - that is, you want to add the results of the lighting passes to the ambient pass. So, you need:

glBlendFunc(GL_ONE, GL_ONE);
Thanks,

That has made the whole scene lighter and looks better.

Now I just need to find why I get different colours in debug mode and release mode.
Quote:Original post by RocketTree
Now I just need to find why I get different colours in debug mode and release mode.


Probably because you're not defaulting your colors to a constant at start-up. In debug mode all uninitialized variables receive a different value than in release mode (which should default all unintialized variables and pointers to zero or NULL, respectively).
Thats what I had thought but I went and checked everything.

I cant seem to find any that are missed out, all my colours are set up as

float black[] = {0.0f,0.0f,0.0f,0.0f};
float green[] = {0.0f,0.5f,0.0f,1.0f};

etc.

Also the lights seem to flicker on and off sometimes in release mode.

In debug mode its starting to get somewhere, multiple shadow casters all overlapping nicely, but cant break the 4 shadows mark for some reason.



Out of the blue it works now

Heres a pic

http://img142.imageshack.us/my.php?image=shadows0jw.jpg

I am projecting one shadow map from slightly different positions to try and create a soft edge. Still cant project more than 4 at once without errors though.

Any help on that would be great thanks.

This topic is closed to new replies.

Advertisement