Graphics Reference
In-Depth Information
Variables and Variable Types
In computer graphics, two fundamental data types form the basis of
transformations: vectors and matrices. These two data types are central to
the OpenGL ES Shading Language as well. Specifically, Table 5-1 describes
the scalar-, vector-, and matrix-based data types that exist in the shading
language.
Table 5-1
Data Types in the OpenGL ES Shading Language
Variable Class
Types
Description
Scalars
float, int, uint,
bool
Scalar-based data types
for floating-point, integer,
unsigned integer, and
boolean values
Floating-point
vectors
float, vec2, vec3,
vec4
Floating-point-based vector
types of one, two, three, or
four components
Integer vector
int, ivec2, ivec3,
ivec4
Integer-based vector types
of one, two, three, or four
components
uint, uvec2, uvec3,
uvec4
Unsigned integer
vector
Unsigned integer-based vector
types of one, two, three, or
four components
bool, bvec2, bvec3,
bvec4
Boolean vector
Boolean-based vector types
of one, two, three, or four
components
Matrices
mat2 (or mat2x2 ) ,
mat2x3, mat2x4,
mat3x2, mat3 (or
mat3x3 ) , mat3x4,
mat4x2, mat4x3,
mat4 (or mat4x4 )
Floating-point based matrices
of size 2 × 2, 2 × 3, 2 × 4, 3 × 2,
3 × 3, 3 × 4, 4 × 2, 4 × 3, or 4 × 4
Variables in the shading language must be declared with a type. For
example, the following declarations illustrate how to declare a scalar, a
vector, and a matrix:
float specularAtten; // A floating-point-based scalar
vec4 vPosition; // A floating-point-based 4-tuple vector
 
 
 
Search WWH ::




Custom Search