Graphics Reference
In-Depth Information
texture values is that you need not use precious texture memory to store the
texture, since you are computing the values on the fly.
In this section, we give some examples of procedural texturing that take
advantage of this per-pixel computation, showing some techniques that you
will find useful. You can take different approaches to this process. In one
approach, you do not use any texture coordinates at all, but work directly
from the geometry and use model, world, or eye coordinates as the basis for
your computation. Examples of this kind of texturing include computing level
lines or geodesic lines as textures. In another approach, you include texture
coordinates in your modeling, but rather than serving as indices into a texture,
the texture coordinates are used as the input to the texture computation func-
tion. Examples of this approach can include computed brick and checkerboard
textures, such as are often found in beginning graphics texts, as well as more
exotic kinds of textures. We use one of the more exotic examples in this section.
Using Model or Eye Coordinates
In the chapter on vertex shaders, we saw how different coordinate systems
could be used to determine object coloring using both model-space and eye-
space coordinates, and we saw a vertex shader that could send either set of
coordinates to the fragment shader. These colorings weren't treated formally
as texture operations, but because their computations can determine the color
of individual pixels, they can be thought of in that way. The figure in the ver-
tex shader chapter showing the results of these two colorings is repeated as
Figure 9.3, and the fragment shader for these two figures is shown below.
Notice how the fragment shader below simply picks up the varying vari-
able vX from the vertex shader, without caring which set of geometry produced
Figure 9.3. The teapots with model-space (left) and eye-space (right) colors, repeated from Chapter 7.
Search WWH ::




Custom Search