Sign in to follow this  
Rot Flapper

Please suggest Strategy for Arbitrary quantity of shadow maps

Recommended Posts

Rot Flapper    152

Dear all,


I’m working on a “project” that is only just now moving towards needing to look at graphics, and specifically some nicer HLSL DirectX graphics.  The “project” is really just a collection of topics that I’m interested in; and has until now focused on the maths involved with collisions (which I’m really pleased with), and various other library functions and stuff.


But now I want to make my graphics better so I can play with my collision volumes in a more exciting way.  In effect I’ve become interested in graphics now.  However in order to proceed, (so that my geometry manager is at least sympathetic to what it will need to do in the future), I’m interested in hearing what you might say on the topic of:


A strategy for dealing with an arbitrary quantity of shadow casting light sources.


I know, I know, and I’m looking forward to building up the simpler techniques.  In fact I’m really looking forward to this, to try it and see, trial and error, and in learning more and more, and making my program do more.  But I have some specific questions.  (It may be that I’m using the wrong language here – but I cannot get google to tell me what I am interested in!!).


There are many tutorials on shadow maps.  I’m using one of Frank Luna’s books as well, which offers some great insight.  However the issue comes when I want more shadows.


1.      The most obvious and easy solution would be to have a second, or third, or fourth, etc., shadow map and process each shadow map and its associated light information on a single shader summing the light’s colour with the ambient colour for each pixel.  In this scenario I would have the option to use up-to the number of shadows my shader was written to support.


a.       In this approach though it seems restrictive.  But also.  It applies all the shadows to all the geometry in the scene, (in terms of checking), even though it might be that for small light radiuses most shadows and lights do not overlap, and do not affect a very significant amount of scene objects.

b.      However with a predicatable quantity of shadow casting sources, that tend to affect everything in the scene each frame, this approach would be best.

c.       Except I do want to not be limited to a fixed amount, more as an academic exercise than anything else at the moment.


Some of the tutorials have suggested expanding the Shadow mapping method to more lights using loops though.  Some have suggested Blending.  Some have suggested multiple render passes.  And it is here that I get stuck, and I can not find out how to proceed with my initial investigation.


1.      Do I render the ambient scene only – (just a bit of diffuse to make unlit curved surfaces seem curved and not flat) – and have fog set.

2.      Then make the First Light’s shadow map / maps

3.      Then with the Z buffer check set to less than or Equal and with blending set to additive. . . .

4.      I render the scene again but for just the colour from the light – with fog being black now

5.      Go back to 2 and do the next light’s shadow map / maps

6.      Untill all my shadow mapped lights are done.

7.      And the scene should now be fully built up with my lights


Is that how you good folks would go about doing it?  If so I like that because I see I might only need to put in the geometry that is overlaped by the light’s radius for each of the light passes, ( both the shadow map texture and main scene render pass).  It sounds quite fast – appart from the Blending being turned on.  How slow is blending in the way described here?  Is this even possible to do – have I missed something? 


Am I right in thinking that the Z Buffer check for the light passes is correct – less than or equal?  I think that this should allow me to get rid of hidden front faces – as they would look horrible with an additive blend operation.  But I have seen reference to people saying that they would turn off depth checks for each light pass.  If the depth check was turned off for the light passes – how would we get rid of hidden/obscured front faces?  Would we need to start doing things with the stencil buffer?


Any tips would be most welcome!







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