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 coordinate
which measures the distance from the plane
. 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
coordinate will set
to the
value of the vertex scaled by 1/1000.
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.