Shadows for terrain.

Started by
6 comments, last by SiliconMunky 20 years, 4 months ago
Ok, so I''m thinking about how to implement self shadowing for the height mapped terrain that I want to render. My question isn''t how to determine which verticies are in the shadows but more specifically, how should I light them? Currently I have one directional light and ambient lighting lighting my world. Any tips to point me in the right direction would be greatly appreciated.
Advertisement
I''ve been thinking about this lately, actually more about the shadows part, but I have thought about actual... what''s the word? composition of lighting for terrain.

I was just looking at some of the images generated in HF-LAB (which were rendered in POV-RAY) and it appears he''s just lighting the heightmap with 2 direct lights, one a reflection of the other (so to highlight the shadowed areas.

If you''d rather not do it this way, you might try specifying an ambient term for the shadows, and still calculating the lighting (dot3) for the shadowed areas, but just multiply it by the shadow brightness (and clamp values below 0.)

You might also try the "sky and ground" vectors approach where you blend the light color between the sky and ground''s based upon the .y component.

The last approach is the most computationally expensive, but can (and should be) pre-calculated.

If you haven''t already, I''d recommend you check out Fast Horizon Computation at All Points of a Terrain by A James Stewart.

You might think of doing a simplified calculation of what he proposes. I''ve calculated the lighting from the 4 primart directions, and used it as an ambient term for a terrain, and it looks great. Only takes a minute or so to calculate for a 256x256 res heightmap too. (It''s not optimized either.)

If you''re interested in any of these ideas (or want to know what the heck I''m talking about) just say so, and I''ll get back to you on it.

-Michael
thanks for the response Thr33d.

My problem isn't about the theory unfortunatly (or maybe it is and I'm too ignorant to realize it), but my problem is how to actually setup the lighting in my program with directx.

Now assume I have two triangles, I've determined that one is in direct sun light and the other is in a shadow. Now how do I display this?

EDIT: readability.

[edited by - SiliconMunky on November 17, 2003 6:46:17 PM]
bump! :D


edit: bump again

[edited by - SiliconMunky on November 21, 2003 12:28:19 PM]
ttt
I made a vertex shadow demo a while back.
It''s simply based on fixed function pipeline (no shader) but gives very good results.. it''s based on interpolations a lot.. just calculates the lighting at each vertex..
It''s fully software but it''s quite fast. maybe it''s possible to do it in hardware too, i didn''t really looked into that..
If you want it, i can send you the parts for the shadow code..
Here''s the link to the demo :
http://www.geocities.com/lionhttp/shadow3.zip

read the readme..
thanks Eddycharly, it looks pretty good. Though I think i''m going to be implementing the shadows of the characters walking on the terrain as well.

Thanks again.
Direct3D doesn''t really do shadowing on it''s own. You''ve got to do it yourself. There are quite a few ways of doing it and it really depends on your engine. You could use pixel / vertex shaders for lighting and shadowing, lightmaps or perspective shadow maps. The choice is yours. Some give better effects than others.

I haven''t got around to experementing with any yet so I don''t know which method''s best. I''ve done light mapping before but it''s a lot of work. Really you want to try and make D3D do the work for you like in shaders or perspective shadow maps.

matt

This topic is closed to new replies.

Advertisement