Graphics Reference
In-Depth Information
uniform vec4 gl_TextureEnvColor[gl_MaxTextureUnits];
uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
// eye linear
uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
// object linear
uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
Fog. All the GLSL fog parameters set by the graphics API are available to your
shaders:
struct gl_FogParameters
{
vec4 color;
float density;
float start;
float end;
float scale; // Derived: 1.0 / (end - start)
};
Varying
GLSL's varying variables provide communication from vertex shaders to frag-
ment shaders. Vertex shaders compute information for each vertex and write
them to varying variables to be interpolated across a graphics primitive and
then used by a fragment shader. GLSL specifies that default interpolations of
varying variables must be done in a perspective-correct manner, so the prob-
lems of perspective correction that we saw in Chapter 1 are not part of GLSL.
Only those varying variables used in the fragment shader must be writen by
the previous shader in the shader pipeline, but that previous shader may also
declare other varying variables. A fragment shader cannot write to a varying
variable.
The varying qualifier can be used only with float variables, floating-point
vectors, matrices, or arrays of these. Structures cannot be varying. Varying vari-
ables must have global scope and must be declared outside of function bodies.
Varying variables may be defined using a modifier that describes how they
are interpolated across a fragment. These modifiers are flat , noperspective ,
and centroid , and were discussed earlier in this chapter.
Search WWH ::




Custom Search