Graphics Reference
In-Depth Information
Attribute
The atribute data qualifier lets you access per-vertex data passed to the graph-
ics card by the OpenGL API functions. Atribute variables have only float, , vec ,
and mat data types, and cannot be declared as arrays or structs. Atribute vari-
ables are only accessible in a vertex shader and are read-only for that shader.
They must have global scope and must be declared outside of function bodies
before they are first used.
Originally, GLSL had built-in variable names for all the standard OpenGL
vertex atributes to give you easy access to data deined by OpenGL vertex
functions. These are
attribute vec4 gl_Color;
attribute vec3 gl_Normal;
attribute vec4 gl_Vertex;
attribute vec4 gl_MultiTexCoordi; i ; // i = 0..7
Uniform
The uniform qualifier identifies global variables whose values are constant
across a graphics primitive. This can be used with any of the basic data types,
or when declaring a variable whose type is a structure, or an array of any of
these. Uniform variables are read-only for all shaders and are initialized exter-
nally either at link time or through the OpenGL API.
GLSL has a large set of built-in uniform variables that let you access the
graphics states set by the OpenGL API in your application. These are listed
below in groups that access similar states.
Primary matrices. OpenGL maintains four primary matrices that are available
to your shaders:
uniform mat4 gl_ModelViewMatrix;
uniform mat4 gl_ProjectionMatrix;
uniform mat4 gl_ModelViewProjectionMatrix;
uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
Derived matrices . OpenGL computes a number of other matrices that are used
in various geometry processing steps. Some of these are inverses or transposes
of the primary matrices, and you should be aware that if the primary matrix
is poorly conditioned, the inverses may have unpredictable values. These
derived matrices are available to your shaders:
Search WWH ::




Custom Search