View Full Version : enLIGHTen me

06-29-2000, 12:21 AM

Well, I'm lost. Don't have a clue how to even start and what everyone is talking about.
What I like to know is some answers to my light questions.

1) Vertex lighting:
Is this just something like calling glColor3f(...); before glVertex3f(...); ?

2) Lightmaps:
These are just textures too, right?
Do I need to use multitextures, or can I place the 2nd texture over the old with some blend function. Or does the texture need a alpha channel too?

any other methods I need to know about?

maybe anyone can hint me on how to create something like this:
the camera is in a cube and three light balls (one red, one green, one blue) are moving with a nice sin function movement through the cube. What's the best way to get the red, green, blue lights on the walls of the cube and blend the lights together when the lights overlap, or something like that.


06-29-2000, 03:01 AM
If you want to do a simple approach(with lot of geometrie) you let OpenGL doing the light.
-Create a cube (-1/-1/-1) - (1/1/1), but not with 6 GL_QUADS, but subdivide each Polygon into 10x10=100 smaller quads.
- generate 1 VertexNormal for each of this vertices pointing in the same Direction like the side of the cube(remember to adjust the normals, because you want to see the inner part of the cube) .
- Place your lights inside the cube and enable lighting and enjoy the show..

This is not the smartest Thing you probably guess. It is just a loosy trick: You subdivide the simple Object to get more lighting details. This costs a lot of performance.
The better (and smarter) way is to do a cube,
and multitexture it with your Texture and a lightmap. If you use Mutitexture, or rendering twice is both possible (the first is faster on new cards, but the second is more compatible)
Then you have to generate 18 Lightmaps (3Lights * 6 Sides), which are simply circles of differrent radius depending on the distance to the side ( use some Vector math: normal Of face*distance between Light and any vertex of Face, i think) I cannot draw a picture here, but it is only a Pythagoras. Project the position of the light onto the face, to get the Center of the circle.
I hope you understand this ( it is actually more complicated to explain something without drawing it..) ;-)
Greetings, Peter