• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Landscape Lighting

This topic is 6074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m looking for some general theory here but if anyone wants to drop in some code feel free What is the best method to produce lighting on a 3D triangle based height map terrain? Currently I have a 24 x 24 sized grid composed of triangle strips (in OpenGL). I calculate the normals and store them per vertex in a 2 dimentional array, when I draw (not in display lists and totally unoptimised at the mo) I just call glNormal3fv() with the array element I want. This involves calculating the normal at every vertex on the height map and averaging them between the normal of the other vertices in the same position. I have seen a triangle strip based method with view frustrum based culling (by Ernest Szoka) over at flipCode (http://www.flipcode.com/cgi-bin/msg.cgi?showThread=05-14-2002&forum=iotd&id=-1) which looks amazing and this is essentially the kind of effect I''m trying to achieve but, one step at a time It may just be me but I think my method is quite a crap solution, does anyone else have a better method? I would want to make it a bit more flexible in the long run so that its not a uniform grid of two triangles (composing a quad) of 0.5 squared. Max

##### Share on other sites
I don't know the best method, but here is one idea -

Assuming you have at least a single directional light source (the sun), you could pre-calculate light values on the terrain and maybe even generate some shadow effects just by pre-determining the color values at the vertices (0.0 is full darkness, 1.0 is full intensity).

What would happen when other light sources come into play, I don't know (If you modulate an additional light source on a vertex that is color 0.0, make sure it is additive and not multiplicative).

You can use the color values you assign to the vertices as indications of how brightly you should render objects in those squares, for objects moving along the ground, anyway. It would make them appear as though they are moving into the shadow of a nearby hill.

Battlezone 1 did this, I think. It was a nice effect, I thought.

[edited by - Waverider on May 30, 2002 10:11:23 AM]

Look here !

##### Share on other sites
Yann, you really really really like that site, don''t you

##### Share on other sites
It''s an excellent resource for everything terrain related

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634087
• Total Posts
3015444
×