Game Development Reference
In-Depth Information
ï?® Spotlights : These are similar to point lights in that they have an explicit
position in space. Additionally, they have a direction in which they shine and
create a light cone that is limited to some radius. A street lamp is a spotlight.
We'll only look into ambient, point, and directional lights. Spotlights are often hard to get
right with limited GPUs like those found on Android devices because of the way OpenGL ES
calculates the lighting. You'll see why that is in a minute.
Besides a light source's position and direction, OpenGL ES lets us also specify the color or
intensity of a light. This is expressed as an RGBA color. However, OpenGL ES requires us to
specify four different colors per light source instead of just one:
ï?® Ambient : This is the intensity/color that contributes to the overall shading of
an object. An object will be uniformly lit with this color, no matter its position
or orientation relative to the light source.
ï?® Diffuse : This is the intensity/color with which an object will be lit when
calculating the diffuse reflection. Sides of an object that do not face the light
source won't be lit, just as in real life.
ï?® Specular : This intensity/color is similar to the diffuse color. However, it will
only affect spots on the object that have a certain orientation toward the
viewer and the light source.
ï?® Emissive : This is totally confusing and has very little use in real-world
applications, so we won't go into it.
Usually, we'll only set the diffuse and specular intensities of a light source and leave the other
two at their defaults. We'll also use the same RGBA color for both the diffuse and specular
intensities most of the time.
Materials
Every object in our world has a material covering. The material not only defines how the light that
is hitting the object will be reflected but also modifies the color of the reflected light. OpenGL ES
lets us specify the same four RGBA colors for a material as we can for a light source:
ï?® Ambient : This is the color that's combined with the ambient color of any light
source in the scene.
ï?® Diffuse : This is the color that's combined with the diffuse color of any light
source.
ï?® Specular : This is the color that's combined with the specular color of any
light source for specular highlight points on an object's surface.
ï?® Emissive : We again ignore this as it has little use in our context.
Figure 11-3 illustrates the first three types of material/light source properties: ambient, diffuse,
and specular.
 
Search WWH ::




Custom Search