next up previous contents
Next: 6.15 Visualizing Surface Orientations Up: 6. Texture Mapping Previous: 6.13 Texture Coordinate Generation

   
6.14 Color Coding and Contouring

One application for object linear texture coordinate generation is color coding objects by distance. For example, a terrain model can be colored by altitude using a 1D texture map to hold the coloring scheme and specifying a generation function for the s coordinate which measures the distance from the plane y = 0. Suppose that the vertex coordinates are specified in meters and distances less than 50 meters are colored blue, distances between 50 and 800 meters green, distances between 800 and 1000 meters white. This means that a 1D texture map is created with the first 5% blue, the next 75% green and the remaining 20% white. A 64 or 128 element texture map provides enough resolution to distinguish between the levels. Specifying GL_OBJECT_LINEAR for the texture generation mode and an GL_OBJECT_PLANE equation of (0, 1/1000, 0, 0) for the s coordinate will set s to the y value of the vertex scaled by 1/1000.

 

% latex2html id marker 5754
\fbox{\begin{tabular}{c}
\vrule width 0pt height 0.1...
...}}{\small Figure \thefigure . Contour Generation Using TexGen}\\
\end{tabular}}

The same basic technique can be used to draw contour lines on an object, for example, in topography applications to indicate lines of constant elevation. For this example, a 1D texture map is used which is all one color except at regularly spaced intervals (say, every eighth texel) where a tick mark is added in a different color. A coordinate wrap mode of GL_REPEAT is used to create repeating lines across the object being contoured. If a GL_OBJECT_LINEAR generation function is used then the contours are anchored to the model. If a GL_EYE_LINEAR generation function is used then the coordinates are evaluated in eye space and the contours stay fixed in space rather than moving with the object.


next up previous contents
Next: 6.15 Visualizing Surface Orientations Up: 6. Texture Mapping Previous: 6.13 Texture Coordinate Generation
David Blythe
1999-08-06