Game Development Reference
In-Depth Information
Point Light
Viewer
Matrices
Vertex
World Light Position
Light Shininess
Eye Position
Position
Texture Coordiante
Normal
Model Matrix
View Matrix
ModelView Matrix
*ModelViewProjection Matrix
3455
6631
4588
1245
Vertex Shader
To Fragment Shader
Texture Coordinate
Diffuse Lighting for Vertex
Specular Lighting for Vertex
Figure 4-12. Complex vertex shader
The vertex data being sent to the vertex shader now includes the texture coordinates and the vertex
normals, as well as the vertex position.
There is also new data in the form of lighting. The world position of the light and the light's shininess are
input to the vertex shader. The location of the viewer or eye position is also input to the vertex shader.
The lighting and viewer information is used to determine the diffuse and specular colors at each vertex.
The output to the fragment shader includes the texture coordinate, the diffuse and specular lighting
for the vertex. I will discuss lighting, including the vertex and fragment shaders that are needed to
perform this lighting, later in this chapter.
Finally, in this topic, we store the actual individual vertex and fragment shaders files in the res/raw
directory.
Overview of Fragment or Pixel Shaders
Fragment shaders are used to determine the color of the pixels on the screen of a rendered 3D
object. Listing 4-4 outputs the color passed in from the vertex shader in the previous section through
the varying vector variable Color .
 
Search WWH ::




Custom Search