PDA

View Full Version : Some lighting questions!



Oliver LS
03-23-2002, 06:07 PM
The situation: A large amount of triangles forming 'terrain'.
The problem: getting it to light and look anywhere near decent!

So far, I've gotten faces to normalize and light 'correctly'. It just doesn't look anywhere near right though.. the first problem I guess is that I need to learn how to normalize by vertex. If I have a vector that represents the normalized face, how can I use this to get vertex normals? How do I implement them in my code, a glNormal3f() before each vertex is drawn I suppose?

My next problem, can somebody post a chunk that initializes a light that would be decent for this kind of situation? At this point in time, everything seems very "very dark/very light".. it just doesn't look right at all. I've tried changing all the settings, but without much real luck. Also, let's assume the area i'm trying to light is up to maybe, 400x by 400z by +- 20y. Should I be using a single non directional light, centered above it all? Or should I be doing things very differently?

Thanks a lot for anybody that can try to help me out on this one.

-Oliver

zed
03-23-2002, 08:49 PM
most terrains are lit by the sun ( a directional light)
set ambient to 0.2,0.2,0.2 + diffuse to 1,1,1 for good contrast (not realistic though)
anyways

theres a lot of info about calculating normals on the net a quick way which looks half ok is

u wanna find the normal for vertice C, A is the vertice to the north, B west etc

.A.
BCD
.E.

normal = CROSSPRODUCT( (A-E), (B-D) )