Graphics Reference
In-Depth Information
Goals
Primary: speed; secondary: image quality
Vertex, Tessellation Control, Tessellation Evaluation,
Geometry, Fragment
Shader Types
Shader Variables
Atribute, Uniform, Constant, Out, In
Coordinate Systems
Model, World, Eye, Clip
Noise
Either as a texture or using the built-in function
Compile Shaders
Done by the driver
GLSL shader code looks much like C, with the usual operators and logic.
Preprocessor commands such as #define , #ifdef , and the like are available.
GLSL has some extensions to support graphics operations. These include a
number of new types, including some built-in vector and matrix types that are
probably new to you, but that make life in graphics much easier.
Integer scalar and vector types: int , ivec2 , ivec3 , ivec4 .
Real-valued scalar and vector types: float , vec2 , vec3 , vec4 .
Matrix types for square real-valued matrices: mat2 , mat3 , mat4 .
Matrix types for non-square real-valued matrices: mat3x2, etc.
Boolean scalar and vector types: bool , bvec2 , bvec3 , bvec4 .
A sampler type to access textures.
The new vector and matrix types in GLSL require some new kinds of
access and operations. Many familiar operators are overloaded to handle vec-
tors and matrices . The familiar multiplication operator * has some new mean-
ings. For the statement m*n , we have four new meanings:
If m is a scalar and n is a vector or matrix, then m*n is a vector or matrix of
the same size as n whose entries are the original vector or matrix entries,
each multiplied by m .
If m and n are both vectors of the same size, then m*n is the scalar prod-
uct (component-by-component product) of the vectors, not their dot
product.
If m is a matrix and n is a vector of compatible size, then m*n is a vector of
the appropriate size that is the usual matrix*vector product.
If m and n are both matrices of compatible sizes, then m*n is a matrix of the
appropriate size that is the usual matrix*matrix product.
A number of other operations have been added, and many operations
have been extended to operate on entire vectors or matrices.
Access to components of vectors involves another set of new operations.
Vector components may be accessed with the familiar [index], or they may use
symbolic names, called name sets , that are familiar for the meanings of different
Search WWH ::




Custom Search