Graphics Reference
In-Depth Information
vec4 aVertex —the coordinates of the current vertex in model coordi-
nates.
vec3 aNormal —the coordinates of the current vertex normal in the origi-
nal coordinates.
vec4 aColor —the color defined for the current vertex, if one has been
defined.
vec4 aTexCoordi ( i = 0, 1, 2, ...)—the level i texture coordinates associ-
ated with the vertex.
There are also some uniform variables that you will use a lot. These vari-
ables are also defined in your application and are available to all your shaders.
In the examples above you saw some of these variables involved in the coor-
dinate computations. Again, these use our name convention and, noting that
these names are chosen for clarity of presentation, we have
mat4 uModelViewMatrix —the ModelView matrix, the product of the
viewing and modeling transformation matrices, that is active for the par-
ticular vertex.
mat4 uProjectionMatrix —the matrix of the projection transformation
that is active for the particular vertex.
mat4 uModelViewProjectionMatrix —the product of the ModelView
matrix and the Projection matrix.
mat3 uNormalMatrix —the normal matrix that is active for the particular
vertex (as we will see, this is the inverse transpose of the ModelView
matrix).
Other important uniform variables you will define in your application
define lights and materials. These are described in the discussion of uniform
variables below.
The built-in vertex shader output variable gl_Position is a particularly
key variable, because you set it as the final vertex position for the remain-
ing geometry processing. Another vertex
shader output variable you may use is
gl_PointSize .
There are two fragment shader vari-
ables you will use a lot. These are, in a
sense, the primary output variables from
a fragment shader; you give them values
to set the properties of each pixel as the
fragment is processed. They let you set the
color and depth for a pixel, respectively.
Technically, none of the coordinate
systems are part of GLSL, but
they are available by applying
GLSL operations. World space is
not available with fixed-function
OpenGL but requires the ability to
define your own transformations,
which, of course, shaders let you do.
Search WWH ::




Custom Search