Lighting
Lighting calculations are nothing more than raw math. In dealing with hardware lighting, intensity is assigned per-vertex, resulting in vertex lighting. Unfortunately, traditional vertex light can often prove to be very inaccurate, with a maximum of three different intensities per-triangle. Thus, large triangles prove to have unsightly results, as can be seen in games such as Quake III when vertex lighting is enabled. When a scene or object uses many, very small triangles the quality can be considerably better - though overall quality will depend on the particular situation.
![3D Basics: AGP, T&L, & Texturing [ Vertex lighting @ 640 x 480 ] > View Full-Size in another window.](images/1-s.jpg) Vertex lighting
|
|
![3D Basics: AGP, T&L, & Texturing [ Q3 with lightmap @ 640 x 480 ] > View Full-Size in another window.](images/2-s.jpg) Q3 with lightmap
|
|
When doing vertex lighting, there are several different types that can be used. A Global Light is very general in that it lights all the vertices equally. This is the most basic form of lighting and is extremely fast. If a developer wanted a constant level of lighting throughout an environment, a Global Light would be the route to go. Uniform Lights emit light equally in all directions from a set point. As the viewer moves further away from this type of lighting it will gradually get dimmer. This requires slightly more computation than a Global Light.
Directional Lights use distance and direction to determine intensity. So if a vertex is directly in front of a directional light it will be very intense, while if it is off to the side, it will be dimmer. This type of lighting is even more complex and can potentially show significant slow down within a lighting engine. Finally, a Spot Light is a very focused light that radiates a set area. Such a light might be used for sunlight shining down through a skylight window. Being the most complex type of lighting, it can offer considerably slowdown, depending on the capabilities of the lighting engine.
![3D Basics: AGP, T&L, & Texturing [ The 8-light<br>test is a good example<br> of directional lights @ 640 x 480 ] > View Full-Size in another window.](images/3-s.jpg) The 8-light test is a good example of directional lights
|
|
![3D Basics: AGP, T&L, & Texturing [ The headlights illustrate<br>spot lights @ 640 x 482 ] > View Full-Size in another window.](images/4-s.jpg) The headlights illustrate spot lights
|
|
Typically, when using with hardware lighting, 8 different lights can be used per-vertex as is specified by OpenGL. Eight lights, however, can be very computationally heavy, so typically this will slow a present-day consumer level T&L engine by a considerable measure.