<p>The common names for the components of texture coordinates are U and V. However, because the next letter used (for 3D textures) is W, that causes a conflict with the names for the components of a <em>position</em>: X, Y, Z, and <strong>W</strong>.</p>

<p>To avoid such conflicts, OpenGL's convention is that the components of texture coordinates are named S, T, and R. Thus, you have function calls like this:</p>

<pre><code>glTexParameter(..., GL_TEXTURE_WRAP_S, GL_REPEAT);
</code></pre>

<p>Where <code>GL_TEXTURE_WRAP_S</code> refers to wrapping in the S component of the texture coordinate.</p>

<p>Unfortunately, OpenGL picked S, T, and R long before GLSL and <a href="https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling">swizzle masks</a> came around. R, of course, conflicts with <strong>R</strong>, G, B, and A. To avoid such conflicts, in GLSL, the texture coordinate swizzle mask uses S, T, <strong>P</strong>, and Q.</p>

<p>In GLSL, you can swizzle with XYZW, STPQ, or RGBA. They all mean exactly the same thing. So <code>position.st</code> is exactly the same as <code>position.xy</code>. However, you're not allowed to combine swizzle masks from different sets. So <code>position.xt</code> is not allowed.</p>

CC BY-SA 4.0
2020-12-09T03:46:26.923Z
LOL What a mess !
Michael
CC BY-SA 4.0
2020-12-09T05:11:11.117Z
@Michael: What's "mess"y about it?
Nicol Bolas
CC BY-SA 4.0
2020-12-09T06:08:52.570Z
The way they name everything. I was so confused until I saw your answer.
Michael
CC BY-SA 3.0
2017-01-13T19:41:42.197Z
2017-01-14T00:12:14.447Z
2017-01-14T00:12:14.447Z
Nicol Bolas
<p>I've seen the term <code>st</code> come up a few times when looking at other OpenGL fragment shaders. However, I don't know what it stands for or what it's used for. Here's an example:</p>

<pre><code>uniform vec2 u_resolution;

vec2 st = gl_FragCoord.xy/u_resolution;
</code></pre>

<p>I can understand that this is converting the pixel coordinates into normalized coordinates of 0.0 - 1.0 instead of 640 x 480 (for example).</p>

<p>I've also seen things like <code>position.st</code>.</p>

<p>What does it mean?</p>

<opengl>
What does "st" mean in the context of OpenGL?
Edward Loveall
# What does "st" mean in the context of OpenGL?

(Asked by: username_0 on 2017-01-13)

I've seen the term `st` come up a few times when looking at other OpenGL fragment shaders. However, I don't know what it stands for or what it's used for. Here's an example:

```
uniform vec2 u_resolution;

vec2 st = gl_FragCoord.xy/u_resolution;

```

I can understand that this is converting the pixel coordinates into normalized coordinates of 0.0 - 1.0 instead of 640 x 480 (for example).

I've also seen things like `position.st`.

What does it mean?

**Tags:** opengl


---

## 1 answers

### Answer by username_1 on 2017-01-13. Score: 34 | Accepted answer

The common names for the components of texture coordinates are U and V. However, because the next letter used (for 3D textures) is W, that causes a conflict with the names for the components of a *position*: X, Y, Z, and **W**.

To avoid such conflicts, OpenGL's convention is that the components of texture coordinates are named S, T, and R. Thus, you have function calls like this:

```
glTexParameter(..., GL_TEXTURE_WRAP_S, GL_REPEAT);

```

Where `GL_TEXTURE_WRAP_S` refers to wrapping in the S component of the texture coordinate.

Unfortunately, OpenGL picked S, T, and R long before GLSL and [swizzle masks](https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling) came around. R, of course, conflicts with **R**, G, B, and A. To avoid such conflicts, in GLSL, the texture coordinate swizzle mask uses S, T, **P**, and Q.

In GLSL, you can swizzle with XYZW, STPQ, or RGBA. They all mean exactly the same thing. So `position.st` is exactly the same as `position.xy`. However, you're not allowed to combine swizzle masks from different sets. So `position.xt` is not allowed.

> **Comments:**
> **username_2**: LOL What a mess !  
> **username_1**: @username_2: What's "mess"y about it?  
> **username_2**: The way they name everything. I was so confused until I saw your answer.  

---

