What do the letters in stpq stand for? (GLSL)

xyzw, and rgba, I get. What's stpq?? (Yes, I know they're intended for texture coordinates.)

It's just a convention to be able to address texture coordinates. Generally, you'd only need two or three dimensions. Not sure if a 4th dimension is ever used by anyone - maybe it's just added for completeness, or it might be useful as a time variant component, such as for Perlin noise computation.

Why the letters stpq? Well, a valid question would be, why not uv instead of st? I am not sure which convention came first in the history of texture mapping computer graphics. Nowadays, using uv is generally more common, but st is also still being used.

To be able to access 3D textures you'd need a 3rd dimension. When using uv, the convention suggests to use 'w'. However, this one is already taken as the homogeneous part of the xyzw mapping. stuv or uvst can't be used, since they mean the same thing (s is synonymous to u, and so are t/v), which would cause confusion. So the next available letters backwards in the alphabet are p and q, with xyzw taken, uv blocked, and r taken by the color component.

Hence, stpq. I guess uvpq would have been another valid defintion.

I believe it's a common mathematical convention that refer to points in a plane/box/coordinate space(wiki).

Mathematical definition of plane

...where s and t range over all real numbers, v and w are given vectors defining the plane, and r0 is the vector representing the position of an arbitrary (but fixed) point on the plane.

You can define higher dimensions in the same manner.

Thus, the notation is stpq for points in the texture coordinate set.

The main thing is that STPQ must avoid reusing letters of the other two (RGBA, XYZW.)

It also suggests that they thought a typical use would be to store a pair of texture coordinates: (ST) and (PQ).

It's interesting that they avoided UV for one of the pairs, even though that's both a time-honored way to refer to 2D texture coordinates, and directly follows ST, e.g. why not UVST?) So it appears to have been deliberate, but I don't know why. (Maybe they wanted to avoid confusion when discussing UV coordinates versus how those coordinates are actually stored in the vector?)

From The Art of Texturing Using The OpenGL Shading Language:

“… for the sake of code clarity and convention: for a position we will use {xyzw}, {rgba} for a color and {stpq} for texture coordinates.”


Edit:

stpq = xyzw = 3 dimensional texture coordinates + inverse scale factor

As far as I know s, t, r, q have been the official OpenGL texture coordinates from the beginning (i.e. back in the early 1990s). (I’m not sure when they switched to s, t, p, q. But you can probably find out by going through the specs.) The first version of the OpenGL Programming Guide explains (see http://fly.cc.fer.hr/~unreal/theredbook/chapter09.html ):

“Texture coordinates can comprise one, two, three, or four coordinates. They’re usually referred to as the s, t, r, and q coordinates to distinguish them from object coordinates (x, y, z, and w) and from evaluator coordinates (u and v; see Chapter 11 ). For one-dimensional textures, you use the s coordinate; for two-dimensional textures, you use s and t. Currently, the r coordinate is ignored (although it might have meaning in the future).”

I assume the reason for “s” is that “s” is often used to identify a “scalar”, i.e. a one-dimensional number. “t” is just the next letter in the alphabet. They couldn’t continue with “u” and “w” because they used those for evaluator coordinates; thus, they used the letters before. “q” being somewhat more exotic as a variable (“r” is very often used in mathematics as the “radius” or generally a point in spherical or polar coordinates), thus, the fourth coordinate was named “q”. You might also notice that they use all the letters at the end of the alphabet for such coordinates (q, r, s, t, u, v, w, x, y, z).

Of course, later they found out that “r” conflicts with the “r” in RGBA and therefore switched to “p”.

Animation tools would use “t” for time and therefore wouldn’t use “s” and “t” for texture coordinates. Thus, they used “u” and “v” because they didn’t care about evaluators. (Those are used to describe parametric surfaces such as spline patches. However, evaluators where never implemented in commercial hardware (as far as I know) and therefore were dropped from OpenGL at some point.)