Graphics Reference
In-Depth Information
that take texture coordinates as their starting point. And later, in Chapter 15
on scientific visualization, we will show how textures can be used to pass data
to shaders.
Texture Coordinates
Texture coordinates specify the coordinates in texture space for each vertex of a
graphics primitive. Texture coordinates are not part of the basic geometry of
a primitive, but rather are an atribute atached to each vertex. In the vertex
shader, the per-vertex texture coordinates are typically assigned to variables
that can be interpolated by the rasterizer across the entire polygon and then
given to the fragment shaders.
In the previous chapter on fragment shaders, you saw that you access the
interpolated texture coordinates with the texture coordinate variables we have
been calling vST in the vertex shader, and that you can get the RGBA color of
a texel from one of the texture( ) functions. You are not limited to using just
the single texels at those given texture coordinates, however. You can also use
any texture coordinates you need in developing the color of the pixel. As an
example, in the chapter on scientific visualization, we will describe the line
integral convolution ( LIC ) process that probes the texture map along specific
function streamlines to compute the color of each pixel. You can use a great
deal of creativity in how you use textures.
Traditional Texture Mapping
Traditional OpenGL texture mapping uses a number of functions that define
the way a texture is read, stored, accessed, and processed. The apparent com-
plexity comes mostly from the flexibility that a generalized graphics API must
have in order to be used so widely. If you are writing your own texture func-
tions in a fragment shader, you can implement just those operations you need,
which should make the task less intimidating than it might appear.
Your experience is that fixed-function OpenGL supports four kinds of
textures: 1D, 2D, and 3D textures, and cube maps. It also supports multitextur-
ing. Our goal is to see how you can create each of these standard functional-
ities with fragment shaders.
When you first encounter texturing in OpenGL, you find that to use tex-
tures, you must first set up a number of texture properties. You must associate
 
Search WWH ::




Custom Search