Game Development Reference
In-Depth Information
Basic Data Types
The basic data types for the OpenGL ES 2.0 shader language are:
void: No function return value
bool: Boolean
int: Signed integer
float: Floating scalar
vec2, vec3, vec4: 2, 3, and 4 component floating-point vector
bvec2, bvec3, bvec4: 2, 3, and 4 component Boolean vector
ivec2, ivec3, ivec4: 2, 3, and 4 component signed integer vector
mat2, mat3, mat4: 2-by-2, 3-by-3, and 4-by-4 float matrices
sampler2D: Used to represent and access a 2D texture
samplerCube: Used to represent and access a cube mapped texture
float floatarray[3]: One-dimensional arrays; can be of types such as floats, vectors,
and integers
Vector Components
In the vertex and fragment shader language, you can refer to vector components in different ways.
For example, you can address components in a vec4 type in the following ways:
{x, y, z, w}: You can use this representation when accessing vectors that
represent points or normals.
vec3 position;
position.x = 1.0f;
{r, g, b, a}: You can use this representation when accessing vectors that
represent colors.
vec4 color;
color.r = 1.0f;
{s, t, p, q}: You can use this representation when accessing vectors that
represent texture coordinates.
vec2 texcoord;
texcoord.s = 1.0f;
 
Search WWH ::




Custom Search