How to mix static shadow with dynamic shadow

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
liudingjun
Posts: 15
Joined: Thu May 26, 2011 12:32 pm

How to mix static shadow with dynamic shadow

Post by liudingjun »

hello, while I was playing GEAR of WAR, I noticed that this game did a very good job on mix static shadow with dynamic shadow. The static shadow are pre-computed in the light map or RNM, and dynamic shadow cast from the the chracters.
When the character enter some dark area, I could not see those area become more darker. When the character enter some bright area, I could see that those area become dark but consistant with other dark area.
How do they do that?
Maybe I could bake two different light maps, one is much dark without this light, and other one is much bright with this light.
In the game run time, I choose different lightmap based on the value from character shadow map. If the current pixel is in the shadow of the character, the dark light map will be selected. Otherwise, I pick the bright one.
This solution should works fine. But it will increase a lots of texture memory, and the situation will become more complex when more than one light exist.
So Is there anybody have some idea to solve this problem?
Thanks a lots!
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: How to mix static shadow with dynamic shadow

Post by Radikalizm »

This actually sounds like a regular HDR lighting pipeline with tonemapping, based on your description (although I'm not sure that's what you mean)

Do you have any videos showing the effect?
liudingjun
Posts: 15
Joined: Thu May 26, 2011 12:32 pm

Re: How to mix static shadow with dynamic shadow

Post by liudingjun »

hi, I think some body may have the same problem with mine.
You could check the following link here : http://forum.unity3d.com/threads/32385- ... ic-shadows
Image
Just as you see from the above image, the cube is a moving characters in the game scene. The whole scene (not include the white cube) painted with the light maps. Here the shadow effect cast by the cube is very different from those which picked from pre-computed lightmaps. Of course, the shadow from the cube is real time. That means, I may use Dynamic Shadow Map to create the cube shadow map. Right now, I am looking for a way to make both of them (light map shadow and dynamic real time shadow) look the same. Any body have some ideas?
3Q You!
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: How to mix static shadow with dynamic shadow

Post by Mel »

Something quite curious would be to have "premade" shadow volumes that rendered the same as the realtime stencil shadows, but without the need to precalculate them.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: How to mix static shadow with dynamic shadow

Post by ACE247 »

So you could recalculate when a node is moving and then store its dynamic shadow as static in the lightmap but then you have to remove your previous shadow from the lightmap once you've moved again.... Why not just load the whole lightmap as an additive onto the dynamic shadow buffer. and then set the whole buffers color for the shadows the same. (Im not the best with this kinda stuff, but is that feasible?)
fmx

Re: How to mix static shadow with dynamic shadow

Post by fmx »

How difficult is it to edit the colour calculations in the shader to make the shadows match?
The only difference seems to be that the cube shadows look more transparent, just make the dynamic shadows darker (less luminance and more alpha)
That is all you have to do IMO

edit:
on second thought, I can see the dynamic shadow is bleeding "over" the static shadow so that wont work :?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: How to mix static shadow with dynamic shadow

Post by Mel »

I have a suggestion for the dynamic/static shadow blending. Basically, If you use lightmapping, you can multiply the shadowmap by the lightmap, and calculate the luminance of the result to blend it with the ambient lighting. This, obviously, overrides the lightmap color, but almost blends perfectly the shadowmap with the lightmap.

Code: Select all

 
lightmapColor*=shadowmapValue;
colorIntensity = (lightmapColor.r+lightmapColor.g+lightmapColor.b)/3.0;
lightCol = (1-colorIntensity)*ambient+(colorIntensity)*lightmapColor;
 
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply