# The Industry's Foundation for High Performance Graphics

1. ## OpenGL Lights

Hi,
I'm the very beginner so don't laugh

I heard that OpenGL can handle only 8 different lights (LIGHT0-LIGHT7). It's very few I think... or maybe i'm wrong. But lets look at Unreal Tournament for example, I made some maps in UnrealED and there was a lots of lights (even few hundreds sometimes). So... how can OpenGL handle only 8 if my UT (using OpenGL renderer) can handle 'em all and everything is OK? Are these a different kind of lights? Or maybe there's some kind of other renderer working parallel with OpenGL that can handle the rest?

Thanx

2. ## Re: OpenGL Lights

In fact OpenGL use a max of 8 Lights when rendering a single Triangle.
So in a renderer you should not have more than eight light for a triangle, but a lot of lights for a scene can be rendered by selecting wich lights are coloring a given triangle.

So you need to focus the mathematical way that your renderer must manage lights in a scene and lights for triangle.

3. ## Re: OpenGL Lights

So if I understand properly I can build a scene with more than 8 lights by selecting which light colors a triangle ? How can I select it ?

Maybe I tell what I wish to do. I have 3 cubes (6 polys for each) and I wanted to set 3 different lights for each cube. Should I use triangles instead of polys ? I know that Tris are better but is that necessary ?

I will be grateful for any answers
Thanx

4. ## Re: OpenGL Lights

Originally posted by <alex>:
So if I understand properly I can build a scene with more than 8 lights by selecting which light colors a triangle ? How can I select it ?

Maybe I tell what I wish to do. I have 3 cubes (6 polys for each) and I wanted to set 3 different lights for each cube. Should I use triangles instead of polys ? I know that Tris are better but is that necessary ?

I will be grateful for any answers
Thanx
Yes use GL_TRIANGLES not GL_POLYGONS speed reasons... You select the light by

Code :
```//change GL_LIGHT0 to GL_LIGHT1-7
//you will need to check the specs on gllights
//for each light after 0 is setup differently with different setup values
//so make sure you set your light you want enabled with some known values
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);```

5. ## Re: OpenGL Lights

Let's get one thing straight, the lights in unreal are not renderd as lights in openGL.
Unreals lights are baked into lightmaps when you export the map and is only then rendered in openGL as textures.

Any dynamic light's you see in most modern games are rendered one at the time using a fragment program and it is only in rare occations you need to use anything more than LIGHT0.

In your case i would reccomend setting the lights you need for a cube, render a cube the set the next set of light for the next cube and so on.
Allso quads work as well as triangles for this.

6. ## Re: OpenGL Lights

OK thank you guys very much I thought that unreal's lights are different but i wasnt sure I'll change quads into tris and set the lights
thanx one more time

7. ## Re: OpenGL Lights

Triangles are more optimized than quads, but the real winner is triangle strips. I won't explain them here, but if you want truly optimized rendering, use triangle strips (or triangle fans for terrain engines).

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•