September 2018
Intermediate to advanced
472 pages
15h 36m
English
Within the vertex shader, the fourth coordinate of the uniform variable Light.Position is used to determine whether or not the light is to be treated as a directional light. Inside the phongModel function, which is responsible for computing the shading equation, the value of the vector s is determined based on whether or not the fourth coordinate of Light.Position is zero. If the value is zero, Light.Position is normalized and used as the direction toward the light source. Otherwise, Light.Position is treated as a location in eye coordinates, and we compute the direction toward the light source by subtracting the vertex position from Light.Position and normalizing the result.
Read now
Unlock full access