## Recommended Posts

griffin2000    214
I our game we have an environment with multiple lights, several of them dynamic. We can only afford a single volume shadow per object, but none of the strategies I have come up with for choosing a light direction to use to generate a shadow work very well. The simplest approach is to choose the nearest light, this causes obvious jumps as the character moves between lights. The best I came up with is generate a direction and distance for each light and linearly interpolate both seperately, normalize the direction, then scale by the distance (clamped to a sensible minimum). It works better but still has weird artifacts (esp. with lights that move). Has anyone else tried this ? Have you had any luck. What other techniques are out there ?

##### Share on other sites
Cypher19    768
I'd like to suggest just choosing a single important light that will be the sole shadow caster in a scene, with the other lights being decorations. If you want just a single shadow, I think that's the only consistent, aesthetically pleasing solution that you'll be able to get away with.

##### Share on other sites
Guest Anonymous Poster
I don't remember if this is what we ended up using in the final version, but I know at one point, I had something like this (in a game I worked on recently):

1) Calculate direction for each light source
2) Sum all directions, weighted by 1/distance (closer lights contribute more)
3) Normalize the result

If you have directional lights (as opposed to point lights) then this doesn't work exactly, because they lack a suitable distance. In that case you have to just pick some arbitrary weighting factor for those lights. Regardless, this should avoid any discontinuity, and also transition nicely so that the closest light is always the one that's 'obviously' casting the shadow.

##### Share on other sites
SimmerD    1210
If your shadows are really just to place the object in the scene, rather than realistically block light, you could add a large top-down bias to the shadow direction, so that it's always coming roughly from above, but still points away from the light average.

This would give a rough sense of where the main light is coming from, without wildly swinging between lighting angles.