Graphics Reference
In-Depth Information
processing include the choice of projection, the shading to be used, whether
color is specified or computed, and what kind of lighting and material will be
used to set the color of a vertex.
Output from Vertex Shaders
The output from a vertex shader is much the same kind of output as would
come from the vertex processing in the fixed function graphics pipeline. A ver-
tex shader can create and set variables for later use in tessellation, geometry,
or fragment shaders. The vertex shader must also create certain variables that
are needed for rasterization and fragment processing.
The primary responsibilities for the vertex shader in the fixed-function
environment are to compute and pass forward the coordinates of the model,
transformed into clip space, and to compute and pass forward the color of
each vertex.
The special variables that are output for the geometry of the model
include the required variable gl_Position (which holds the 4D vertex position
in clip coordinates), and gl_PointSize (which optionally holds a point size
in pixels). If texturing is to be used, the texture coordinate atribute variables
gl_MultiTexCoordi i must be converted into out variables so that they can be
used in subsequent pipeline stages, including being interpolated by the raster-
izer for the fragment shader.
The vertex shader can also compute the color of each vertex and pass it
along to the fragment processor to use.
A uniform variable could contain any information that should be con-
stant across a geometric primitive. That is a uniform variable's scope . Uniform
variables may be read in the vertex shader, in a tessellation shader, in a geome-
try shader, or in a fragment shader. Examples of such variables include glman's
range variables, which you define in GLIB files.
Other variables may be defined by the vertex shader to transfer any
kind of per-pixel data to the tessellation, geometry, or fragment processing
stage. These may include transferring the value of user-deined atribute vari-
ables to variables defined in the ver-
tex shader, for example. It may also
include creating appearance informa-
tion such as pixel colors, or geometric
information such as normals or light
direction, which can later be used in
tessellation, geometry, or fragment
processing.
Figure 7.2. The inputs and outputs for a vertex shader.
Search WWH ::




Custom Search