| <<< Common vector operators | Index | GLSL Efficiency >>> |
Individual elements of vectors and matrices can be accessed via name component accessors
xyzw – typically for positions
rgba – usually for colors
stpq – usually for texture coordinates
For example,
my_vec.x = 4.0f;
my_vec.xy = vec2( 1.0f, 5.0f );
my_vec.xyz = another_vec.xyz;
float pos_z = pos.z;
color = color.abgr; // components reversed in color (vec4)
color.abgr = color; // the same resuilt
The last example is called component swizzling
| <<< Common vector operators | Index | GLSL Efficiency >>> |