Game Development Reference
In-Depth Information
DrawMesh() is called from the DrawObject() function in the Object3d class. The GetVertexAttribInfo()
function gets the vertex attribute handles that are needed for the DrawMesh() call.
The DrawObject() function in the Object3d class will be the main entry point where 3D objects are
rendered throughout this topic.
Lighting
In this section, I cover OpenGL ES 2.0 lighting in depth. I start off with an overview of lighting.
Then I discuss our custom PointLight class and how lighting is performed in the vertex and fragment
shaders.
Overview of Lighting
You can model lighting by dividing lighting into three separate types:
Ambient Lighting: This type of lighting models the lighting on an object that is
constant at all object vertices and does not depend on the position of the light.
Diffuse Lighting: This type of lighting models the lighting on an object that depends
on the angle that the object's vertex normals make with the light source.
Specular Lighting: This type of lighting models the lighting on an object that
depends on the angle that the object's vertex normals make with the light source
and also the position of the viewer or camera.
The key components in determining lighting are shown in Figure 4-21 , which are
Light Vector: The vector that represents the direction from the object's vertex to the
light source.
Normal Vector: The vector that is assigned to an object's vertex that is used to
determine that vertex's lighting from a diffuse light source. Normal vectors are also
vectors perpendicular to surfaces.
Eye Vector: The vector that represents the direction from the object's vertex to the
location of the viewer or camera. This is used in specular lighting calculations.
Point Light: A light source that radiates light in all directions and has a position in
3D space. A point light contains ambient, diffuse, and specular lighting components.
 
Search WWH ::




Custom Search