Graphics Reference
In-Depth Information
You can also create your own per-vertex atribute variables. These can
be used to send per-vertex data values, as well as geometry, into the graphics
pipeline so that the graphics functions can use the data in developing images.
This might include per-vertex application-specific data such as elevation, tem-
perature, density, or speed, which can be used in computing the image. We
will see some examples of the use of application-deined atribute variables in
Chapter 15.
Uniform variables are constant across a graphics primitive and are read-
only to all shader types. As with atribute variables, uniform variables come
from the OpenGL application program.
The GLSL built-in uniform variables reflect the kind of information that
an application would specify, including such items as
The primary OpenGL matrices, such as the ModelView matrix, the
Projection matrix, and the Texture matrix.
The derived OpenGL matrices, such as the Normal matrix, the
ModelViewProjection matrix, and the ModelViewInverse matrix.
The front and back clipping planes and the user-defined clipping planes.
The material properties: ambient, diffuse, specular, shininess, and emis-
sion.
The full set of light properties, including colors, position, direction, cut-
of, and atenuation properties.
The texture environment.
The fog data, such as color, density, start, and end.
Besides the built-in uniform variables, an application can provide user-
defined uniform variables as needed through the GLSL API. The mechanics of
defining and initializing these variables will be described in Chapter 14. These
variables can be used in similar ways as the system-deined atribute variables
if you are working with data that is constant over a graphics primitive.
Another vertex shader input can come from texture coordinates that are
defined in modeling operations. Textures can be used in vertex shaders for a
variety of applications, such as displacement maps. However, the most com-
mon use of texture coordinates in a vertex shader is to pass them along as out
variables so they can be interpolated by the rasterizer for use by the fragment
shader, as we see in the next section.
Vertex shaders can also accept uniform sampler variables to access several
kinds of textures. We discuss sampler variables in more detail in Chapter 9.
The inputs to the vertex shader are not just data but can also affect the
kind of processing that will be done. Those that determine different kinds of
Search WWH ::




Custom Search