Graphics Reference
In-Depth Information
Figure 8.1. The place of the fragment shader in the pipeline.
Basic Function of a Fragment Shader
The basic function of a fragment shader is to take uniform variables and the
output from the rasterizer and compute the color of the pixel for each frag-
ment. Figure 8.2 illustrates this process, showing first how the distinct verti-
ces of a primitive are processed by the rasterizer to form the set of fragments
that make up the primitive.
Of course, many other built-in properties of vertices besides color and
light intensity can be interpolated in fragment processing. The two most
important of these are texture coordinates and pixel depth. If you are using
texturing, as the texture coordinates are interpolated, you can use these coor-
dinates to sample a texture (or multiple textures) to help determine the colors
of each pixel. We will focus on textures and their contribution to fragment
processing in the chapter on texturing, and will keep our focus on other frag-
ment processing here.
Inputs to Fragment Shaders
There are many different kinds of inputs to a fragment shader from an appli-
cation, from the OpenGL system, or from a vertex shader. By now, these are
Search WWH ::




Custom Search