Graphics Reference
In-Depth Information
else // white if above bound
{ myColor.r = 1.; myColor.g = 1; myColor.b = 1.; }
return myColor;
}
void main( )
{
vec3 color = Rainbow(vMyHeight);
fFragColor = vec4( color, 1.);
}
Another example of using false color is to provide contour lines for sur-
face displays. To do that, you would create and display the surface however
you like, but if the model-space elevation at a particular pixel is within a cer-
tain tolerance of one of the contour line elevations, you color the pixel with
the contour line color, instead of the ordinary surface color. If you are already
using false coloring for your figure, you can include this contour information
in your transfer function; if you are not, you can make a special contour-only
transfer function and apply it in your fragment shader after your other color-
ing operations. See Chapter 15 for more details. This kind of application is
similar to the model-space coloring example shown in Figure 6.3 and is left as
an exercise for the reader.
What Follows a Fragment Shader?
The fragment shader is not the last word on the color of pixels that are writen
to the color buffer. Several steps in the fixed-function graphics pipeline fol-
low the fragment shader. These include depth comparisons if depth testing is
enabled, alpha blending, stencil testing, masking, dithering, and logical raster
operations. Because these are standard fixed-function operations, we won't
go into them further. These operations use information that is not available
to the fragment shader, such as the existing contents of the color and depth
bufers, and are tightly controlled as pixels are inally writen to the color buf-
fer. The fragment shader has some role in these operations, even if it does not
perform them. Depth testing uses the depth output from the fragment shader,
for example, and alpha blending uses the alpha channel that is the fourth coor-
dinate of the fFragColor value.
Search WWH ::




Custom Search