Shadowmapping terrain

Posted By: Damocles

Shadowmapping terrain - 01/30/08 13:58

Here is a shot from a terraineditor I am working on

youtube video

http://de.youtube.com/watch?v=hyRrjEBkA6g


I cut the calulation time for the shadow-map to about 3 seconds.
(depends of course also on the PC, but the calculation should be done under 7 secs on older
computers)
Still having quite smooth shadows.

The level is fully made in the editor, wich took me about 1 minute...
(its still missing ambient objects, like trees)


Posted By: Puppeteer

Re: Shadowmapping terrain - 01/30/08 14:07

Nice, the next step is realtime shadow mapping
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 14:14

Realtime shadows are possible (for RTS)
by simply manipulating the shadowskin according to the model.

Samll units must only draw a few pixels (the shadowmap does not have
a really hight resolution)
By keeping the updates small, its shure possible to make a dynamic shadow
for the moving units.
Posted By: aztec

Re: Shadowmapping terrain - 01/30/08 16:51

looking very fine
looks promising

Regards

Aztec
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 17:39

Here with some Ambinet models





Posted By: frazzle

Re: Shadowmapping terrain - 01/30/08 19:43

Looks pretty neat
Can you specify the way you enhanced the shadows, just being curious

Thanks in progres

Frazzle
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 19:52

its just baking the shadow (with a c_trace determining if a "pixel" can see the sun, then it is dark, else bright)

then a smoothingroutine runs over it, just the same way as you smooth pictures in a 2d Program
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 23:04

here the editor and ingame-scene as video

http://de.youtube.com/watch?v=hyRrjEBkA6g
Posted By: ventilator

Re: Shadowmapping terrain - 01/30/08 23:26

currently the areas behind the hills where the shadows start look strange. i think it would look much better if you used a lighting equation for baking.

just something simple like:

if(in_shadow) brightness = 0;
else brightness = max(0, vec_dot(normal, light_direction));

you could also modulate the brightness with the light color. falloff isn't needed with directional lighting.
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 23:36

Actually the shadow is not calculated by taking the "suns" position for now.
It takes a fixed position by script.
The sun is actually lightnig from a different direction.

When i align sun and shadow, then the mix of dynamic lightning of the terrain and the "baked" shadow will
look better.

I had a shadowbaker before that was more "realistic" by lighning the terrain in contrast to
calculating areas with shadow. but the calculation took almost a minute then.
Posted By: ventilator

Re: Shadowmapping terrain - 01/30/08 23:40

Quote:

When i align sun and shadow, then the mix of dynamic lightning of the terrain and the "baked" shadow will look better.


ah! that explains why the difference looks that extreme.

i still would use a lighting equation though. i don't think that a single vec_dot() would make the calculations take a minute longer. it shouldn't be noticable. what computationally intensive method did you use?
Posted By: Damocles

Re: Shadowmapping terrain - 01/30/08 23:49

I use a quite "straigt forward" approach in C-script with traces, and painting pixels

For the project I have to do a thousand other things like cinematics, triggers, unit-actions/spells etc

So i cant put much time into the shadowbaking for now.

i will come back to your suggestions later in the project.
Posted By: Machinery_Frank

Re: Shadowmapping terrain - 01/31/08 08:12

There is a quite easy approach to render soft lights direclty while you raytrace the pixels of your terrain.

Dont use a single point for the sun - use an area. If you use a squared area then you have 4 points available. Every pixel of the terrain traces to all 4 points.

So if it happens that it hits all 4 of them then it gets full sun light.

If it hits none it is in full shadow.

If it hits only 2 of them it is in half shadow.

The size of the rectangled sun influences the size of the soft-shadows.

The calculation will take 4-times your current time but it might be worth it.
The quality can be better, when you rotate the rectangle like this:
Code:

x
x x x
x


Posted By: Damocles

Re: Shadowmapping terrain - 01/31/08 11:41

I did that in the previous shadowrenderer.
But the probelem is, that the Terrain does not have a resolution
high enough, to make the "curves" in the terrain look smooth.
So when the part of the terrain has a thin angle, so that it is almost in the shadow,
it will be drawn darker. But this makes hard edges between the faces of the terrain,
looking unrealistic.

Thats why I want only tweo choises "dark" or "lit". The smoothing removes hard edges in the
postprocessing.

The "fine" shadow/light differences will then come from the dynamic lightning of the terrain.


in the video you can see that the terrain looks quite nice ingame:

http://de.youtube.com/watch?v=hyRrjEBkA6g



Here with wather. Its quite Flat, so i have to look for a shader that makes it look good, but
does not drain performance.


Posted By: ulf

Re: Shadowmapping terrain - 01/31/08 19:47

wow, i really like your style damocles. its looking simple but effective. thats a good basis for an fps.

can you tell me how you move your units? because i get strange behaviour described in this thread:

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/814408/an/0/page/0#Post814408

when i move something with a constant speed pretty fast in windowed mode. have you tried running in windowed mode?
Posted By: frazzle

Re: Shadowmapping terrain - 01/31/08 19:51

@ Damocles:

That looks nice and flexible
Thanks for commenting your shadow methode.

Cheers

Frazzle
Posted By: Damocles

Re: Shadowmapping terrain - 01/31/08 20:02

The demo on the video was actually taken from a windowed game. (fraps only recorded the window)

I only use fps_max=60; and everything with a time factor.
no timesmooth.

In theory, the movement can only be fluent, if there is no timesmooth,
as this is exactly the timeshift between two frames.

But i think there is a problem when the framerate drops below 16FPS.

Since i have a pretty fast computer now, and alway write the code as fast as possibele, I dont
run into major problems.
Its another thing with slower computers. But on my laptop, the game runs quite smooth too, even when
it is already 5 years old.

I am also very reluctant to shaders/effects, especially if they do not improve the feeling of the game.

The only shader I use is the multi-terraintexture-shader from the templates. (about the only think I find useful for me
from the template source)
© 2024 lite-C Forums