Archived

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

how to create lights

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve had a few drinks tonight, but i''m pretty certain the brain still remembers the answer:

lightmaps are simply a texture that has be pre-made to look as though a light is being shone on it. You can only have a max of 8 lights in OGL or DX, so lightmapping allows you to have more by making a texture which ''looks'' as though it has a light on it, which is then simply mapped onto a poly.

hope i''ve kind of explained it there.

Share this post


Link to post
Share on other sites
Hi, I'm sober
Lightmaps are like textures, just they tell how much light there is on a given texel instead of what color. This is then blended togehter with the actual texture. Lightmaps are usually smaller too.

Edited by - geekster on January 9, 2002 7:01:46 AM

Share this post


Link to post
Share on other sites
If you use standard lights in OpenGL you''ll have to activate them :
glEnable(GL_LIGHTING); // Enable lighting in OpenGL
glEnable(GL_LIGHT0); // Activate light source #1
glEnable(GL_LIGHT1); // Activate light source #2
...

Once a light is defined, you have to set the light source properties (mainly, the light color) and the material properties (the object color and shininess).

Then for each vertex you have to tell the normals using glNormal3f.
OpenGL will do all the computations to enlight the vertices correctly.

At this moment, glColor can give weird results if you don''t know exactly what you do. Don''t use it (at least, not before you know more about the lights).

Lightmaps are very powerful, but are a bit complex to use. I recommend you begin to learn "standard" lights (eg light activated by glEnable(GL_LIGHTING)). Just keep in mind that lightmaps are a new way of lighting, and you shall use them later for particular purposes (realistic rendering, fast rendering, etc).

Share this post


Link to post
Share on other sites
You may not use more than 8 lights.

It''s possible to go over, but as do not recommend to do so, as the OpenGL specifications are "There are n light sources, indexed by i = 0, ..., n-1. (n is an implementation dependant maximum that must be at least 8.)"
So, if you use more than 8 lights, you''ll encounter some problems (like checking if the driver or the graphics card support them) which are not worthy of the pain.

8 is more than enough, believe me.
Moreover, you may not use too many lights in a scene as they tend to slow down dramatically the GPU on most graphics cards. I''d say you shall not use more than 4 lights on current cards.

The number 8 represents the number of visible lights in the current viewing frustum.
Of course your world may contain more than 8 lights, but not all the 8 will be visible simultaneously, hopefully.

Share this post


Link to post
Share on other sites
Yes that''s exactly that !

But if you have more than 8 lights, you have to deal with creating some sort of buffer of lights.
If you have less than 8 lights, initialize them all as soon as you can, and then show or hide them just by switching with glEnable/Disable(GL_LIGHTn) where n goes from 0 to 7.

Share this post


Link to post
Share on other sites