Graphics Reference
In-Depth Information
The MVP matrix is loaded into the uniform for the shader using
glUniformMatrix4fv .
// Get the uniform locations
userData->mvpLoc =
glGetUniformLocation ( userData->programObject,
"u_mvpMatrix" );
// Load the MVP matrix
glUniformMatrix4fv( userData->mvpLoc, 1, GL_FALSE,
(GLfloat*) &userData->mvpMatrix.m[0][0] );
Lighting in a Vertex Shader
In this section, we look at examples that compute the lighting equation
for directional lights, point lights, and spotlights. The vertex shaders
described in this section use the OpenGL ES 1.1 lighting equation model
to compute the lighting equation for a directional or a spot (or point)
light. In the lighting examples described here, the viewer is assumed to be
at infinity.
A directional light is a light source that is at an infinite distance from
the objects in the scene being lit. An example of a directional light is
the sun. As the light is at infinite distance, the light rays from the light
source are parallel. The light direction vector is a constant and does not
need to be computed per vertex. Figure 8-3 describes the terms that are
needed in computing the lighting equation for a directional light. P eye is
P eye
N
0 1 = 0 2
H
0 1
0 2
V
P light
Figure 8-3
Geometric Factors in Computing Lighting Equation for a
Directional Light
 
 
Search WWH ::




Custom Search