Graphics Reference
In-Depth Information
These are very important operations. Fortunately, the necessary informa-
tion is readily available, and the operations you need to perform are expressed
well in the GLSL language, which handles vector and matrix operations with
ease.
However, a GLSL vertex shader does not replace all of the operations in
the geometry pipeline. In particular, it does not replace the operations that
take the clip space to the final pixel space. The specific functions that are still
done by the fixed-function pipeline are
View volume clipping.
Homogeneous division.
Viewport mapping.
Backface culling.
Polygon mode.
Polygon offset.
A key function of a vertex shader is to take all atribute variables and
either use them or copy them into out variables for later shaders to use.
Vertex shaders have several kinds of output. The most important are the
transformed vertices and the color associated with each vertex. Of course, the
vertex shader can compute or re-compute normals and texture coordinates as
well as vertex coordinates. If you use a fragment shader, the vertex processing
can develop variables that let the fragment shader interpolate these properties
as each fragment is developed. By seting up color, normals, or textures with
variables from vertex processing, the fragment shader can carry out sophisti-
cated operations on each fragment.
The vertex shader for
the smooth shading on the
simple sphere of Figure 3.3
is shown below. This
shader code, and the other
shader code examples in
this chapter, will be beter
understood when we have
discussed GLSL in more
depth later in the topic. For
now, though, note that this
shader calculates per-vertex
light intensity by the stan-
dard diffuse lighting com-
The shader code in this chapter uses the name
prefix conventions we introduced in Chapter 2.
Variable names start with a character that indicates
who created it:
a attribute variable
f variable from a fragment shader
g variable from a geometry shader
tc variable from a tessellation control shader
te variable from a tessellation evaluation shader
v variable from a vertex shader
u uniform variable
As in C/C++, constants are generally written in all
caps.
Search WWH ::




Custom Search