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

 0 xyzw, and rgba, I get. What's stpq?? (Yes, I know they're intended for texture coordinates.) more ▼ asked Mar 14 '11 at 02:53 PM Jessy 15.6k ● 72 ● 95 ● 196 Jessy asks a question...how interesting! :) Mar 14 '11 at 03:24 PM OrangeLightning Um, I ask questions almost as much as I answer them, I think! Build knowledge through other people and then share it like they did for you! Mar 14 '11 at 03:34 PM Jessy I thought I could figure this out with a little research and/or thinking, but it's turned into an unexpectedly entertaining question! Looking forward to seeing other responses. Mar 14 '11 at 04:07 PM Bampf Since you know stpq are intended for texture coordinates, and you get the "difference" between xyzw and rgba, doesn't it feel like this is just another way of describing texture coords just like you describe colors or positions? :) Mar 14 '11 at 04:47 PM Statement ♦♦ add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

5 answers: sort voted first
 0 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. more ▼ answered Mar 14 '11 at 04:12 PM Wolfram 9k ● 8 ● 20 ● 52 I've NEVER heard of st. Is this really something people do, use .st? It makes a lot more sense to me to just use .xy, given that uv isn't available. Mar 14 '11 at 04:36 PM Jessy It's used, but imoe uv is generally widely used in computer graphic terms. The reason you probably are more familiar with xyzw is that Unity has Vector classes that expose those members. OpenGL for instance makes use of stpq. http://www.opengl.org/sdk/docs/man/xhtml/glTexCoord.xml DirectX uses the uv?? notation http://msdn.microsoft.com/en-us/library/bb206245(v=vs.85).aspx Mar 14 '11 at 04:53 PM Statement ♦♦ It's not from using Unity, at least primarily. It's from using ANY modeling or animation package on the market. Every single one calls them UVs, or UVWs in the case of Max. Mar 14 '11 at 06:20 PM Jessy Ah yes, according to Statement's statement (couldn't resist ;-) ), st is used in both mathematical context, and in the OpenGL specs - I think that's where I remembered it from. However, the OpenGL definition uses strq, which, once again, is not possible here due to the r already being used. Mar 15 '11 at 01:23 PM Wolfram Maybe we could suggest to have them include uvpq, too :o) since most people associate uv with texture mapping, not st. Mar 15 '11 at 01:26 PM Wolfram add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 I believe it's a common mathematical convention that refer to points in a plane/box/coordinate space(wiki). ...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. more ▼ answered Mar 14 '11 at 04:38 PM Statement ♦♦ 20.1k ● 35 ● 70 ● 175 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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?) more ▼ answered Mar 14 '11 at 04:05 PM Bampf 5k ● 8 ● 19 ● 49 You may have hit the nail on the head in your very last sentence. I think that's why uv was avoided. May 25 '11 at 02:34 PM Joshua add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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.) more ▼ answered Aug 13 '11 at 09:12 AM add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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 more ▼ answered Mar 14 '11 at 03:19 PM efge 5.1k ● 5 ● 14 ● 38 I fail to see how this answers the question. Mar 14 '11 at 03:35 PM Jessy I think its the part "code clarity and convention" that efge tries to communicate. Mar 14 '11 at 04:42 PM Statement ♦♦ I think you should use rgba when dealing with color values, xyzw when dealing with positions and stpq when dealing with texture coordinates. Following the convention it becomes immediately clear whether the values are considered to be used as a color or a coordinate. Mar 14 '11 at 04:44 PM Statement ♦♦ I'll do that when they rewrite GLSL to look like anything anybody uses to create 3D content. :-P Mar 14 '11 at 06:22 PM Jessy add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here