Sign in to follow this  
RocketTree

OpenGL Multiple shadow casters in shadow mapping.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this