Re: [Algorithms] Combining shadow maps and preprocessed lighting
Brought to you by:
vexxed72
From: Alen L. <ale...@cr...> - 2005-10-02 20:19:43
|
>So if a person walks beneath the shadow of a building, he is not shadowed. This only occurs >because I don't render the static objects in to the shadow map. Have you considered a middle-ground solution? Have a software-based shadow map of static geometry for the static light(s) that is precalculated and stored in the main memory. At runtime just check center of the dynamic object's box (or several points on the box) against that map (using the CPU) and see whether and how much is that object in the shadow, then use that info to darken it accordingly. It doesn't actually lay shadows over dynamic objects, only darkens them by average shadowing, but at least they are not standing up full-bright in the shadow. We use that trick with success for sun in our current project. Alen ----- Original Message ----- From: igrok To: gda...@li... Sent: Friday, September 30, 2005 4:33 PM Subject: [Algorithms] Combining shadow maps and preprocessed lighting I've been implementing a technique that seems to be quite popular in games right now. In an outdoor environment, using lightmaps to store light occlusion from the sun, and then combining the results with a shadow map (updated each frame) in a pixel shader. That way, you get nice smooth pre-processed shadows on static objects like buildings, but dynamic or fine-detail objects like people, vehicles or trees can cast shadows using the shadow map. The pixel shader just takes the darker of the lightmap or shadow map. So when a character walks in to a shadowed area, there is none of this 'double-shadows' rubbish, it all blends in correctly. Anyway. all is well and good apart from one thing. I can't see a nice way to use the shadow map to also occlude the dynamic objects. So if a person walks beneath the shadow of a building, he is not shadowed. This only occurs because I don't render the static objects in to the shadow map. If I DO render the static objects in to the shadow map, it is obviously fixed instantly, but then you have the problem that the ground is receiving both the smooth lightmap shadow from a building AND the sharp outline from the shadow map of the same building. This results in the smooth lightmaps being lost as towards the edges where it fades out, the shadow map is being overlaid and is the darker of the two. hmmm. I hope that is a good explanation. :/ The only way I can see to fix it is to have TWO shadow maps. One renders only the non-lightmap objects on to itself, and is used when combining lightmap meshes with dynamic shadows. The other renders every object on to itself, and is used by dynamic objects. But that will be no small hit on the GPU as I'm already rendering several shadow maps to cover the entire scene. It seems such a waste, I feel sure there must be a better way. Can anyone help? |