Skip to main content
gamedev.net
🔒 Locked

Shadow Combining

Started by Lopez 6 replies 1.1k views
Original Post
Lopez
Lopez
Hi there, I've got half a demo up and running, with some pretty cool lightmaps. I'm having shadows cast on the scene for all the scene objects (see piccys). Free Image Hosting at www.ImageShack.us The objects shadows use depth projection, and the scene shadows are all radiosityy light maps. Free Image Hosting at www.ImageShack.us atm, i have a shader for the scene materials that uses 1xdiffuse, 1xlightmap, 1xshadowmap textures, and blends the lightmap with the shadowmap for the final lighting component. This works fine when the object is casting a shadow in a fully lit area, as the shadow will be the ambient component. The problem is, that when the shadows are cast on a darker area of the lightmap, the shadows become unrealistically dark. I somehow need a way of stopping the shadow from being blended as much with the darker areas of the lightmap.
Lopez
Lopez
Sorry, heres the prob....

screen036py.jpg

Lopez
Lopez
Image Hosted by ImageShack.us
zedzeek
zedzeek
a possible solution would be in the fragment shader only sample one of the lightmap or shadowmap eg
shading_val = min( shadow_map, lightmap )
_the_phantom_
_the_phantom_
To be honest, I cant see the problem there.
If you stand around in real life with multiple light sources and watch shadows certain shadows will be darker than others depending on where the light sources are in the world.

Now, if your only lightsource is casting that shadow, then yes you have a problem, however if you have multiple light sources then that effect looks more correct to me.

If you want to see if for yourself, walk outside at night, watch how your shadow is cast and changes as you move around.
IronFox
IronFox
Actually this is a pretty old problem. The combination of more than one type of shadow at the same time would be impossible. But as zedzeek already said nowadays' shaders allow a different approach by clamping (or better choosing) the correct shadow-intensity for each pixel separatly. If you know two shadows (one volume shadow and one texture-shadow for instance) are casted by the same light you might want to choose the more intensive shadow and ignore the other.
This can be done via shaders.
SimmerD
SimmerD
One way to solve the problem is to first mark the shadowed areas, then add in light only after all shadows are marked. You can mark them with destalpha or stencil, or a render-to-texture.

Another way is to use a min function of the light * shadow terms if you have all shadow tersm available in a shader.
xycsoscyx
xycsoscyx
The problem seems to be that since your static lightmaps are calculated using radiosity, there is no perfectly dark areas. On the other hand, your dynamic shadows are just on or off (so your lightmaps fade, but your dynamic ones don't). One solution could be to shadow dynamic objects at half color instead of just going to 0. This would give the illusion that it's not 100% dark there (since radiosity would lighten it up a bit anyways), and better blend with the existing static lightmap (which already isn't 100% dark).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.