See WebGL Specification Vesion 1.0:
4.3 Supported GLSL Constructs
A WebGL implementation must only accept shaders which conform to The OpenGL ES Shading Language, Version 1.00 ...
See the OpenGL ES Shading Language 1.00 Specification :
5.5 Vector Components
The names of the components of a vector or scalar are denoted by a single letter. As a notational convenience, several letters are associated with each component based on common usage of position, color or texture coordinate vectors. The individual components can be selected by following the variable
name with period ( . ) and then the component name.
The component names supported are:
{x, y, z, w}
Useful when accessing vectors that represent points or normals
{r, g, b, a}
Useful when accessing vectors that represent colors
{s, t, p, q}
Useful when accessing vectors that represent texture coordinates
The component names x
, r
, and s
are, for example, synonyms for the same (first) component in a vector.
Note that the third component of the texture coordinate set, r
in OpenGL ES, has been renamed p
so as to avoid the confusion with r
(for red) in a color.
You can also use v[0]
, v[1]
, v[2]
, v[3]
to access the components of a the vector.
This means for a vec4 v;
, v.stpq
is exactly the same as v.xyzw
or v.rgba
.
The s
, t
naming comes from the Plane (geometry), where a plan can be described parametrically as the set of all points of the form R = R0 + sV + tW. (R and R0 are points, V and W are vectors, s and t are real numbers.
v[0]
,v[1]
,v[2]
,v[3]
to access individual members of a vec4. – Rhonda