25

What's the difference between a UV texture coordinate vs. ST texture Coordinate?

I know that UV and ST are used in OpenGL.

I also know that ST are also used in Java.

Acorn
  • 24,970
  • 5
  • 40
  • 69
Nabmeister
  • 755
  • 1
  • 11
  • 20

5 Answers5

36

They mean the same thing, it's just a different naming convention.

U = S = x dimension
V = T = y dimension
Tim
  • 35,413
  • 11
  • 95
  • 121
  • 1
    Actually, in CG you use one pair of those coorfinates to denote the position in texture space, and the other one is in object space. The different APIs sometimes confuse this or use it differently. – Arne May 13 '12 at 06:34
  • 1
    @Arne never heard of this. Can you cite a source? – Stefan Hanke May 13 '12 at 08:06
  • 1
    @StefanHanke Hm, I looked, but cannot find it. Maybe I misremembered. Anyway, this is just terminology. I found Blinn's bump mapping paper very good to understand texture mapping and texture space operations in general (http://research.microsoft.com/apps/pubs/default.aspx?id=73939). – Arne May 13 '12 at 08:56
  • 6
    One minor nit: U and V are usually in the range [0,0 .. w,h], while ST are in the range [0,0 .. 1,1]. At least this is how OpenGL defines it, with the exception of texture rectangles. – kusma Sep 17 '13 at 12:24
  • 6
    Kusma, that's not right. UV are in texture coordinates so will also be between 0 and 1. ST can go above 1.0 but usually gets wrapped down into UV space. – Richard Lalancette Feb 16 '14 at 17:18
  • ST (or STQ) are normalized because they refer to the surface or fragment coordinates. UV are texture space coordinates, so their representation depends on how API treats texture (they are 0-1 for parametric textures but may be expressed in texels for raster textures) – Swift - Friday Pie Aug 14 '19 at 12:19
  • I may be wrong but S T is used for 2 dimensional textures, and UV are additional ones for 3d and 4d textures –  Oct 05 '19 at 08:50
  • T - top, S - side – Vitaly Fadeev Aug 24 '21 at 08:21
34

Computer graphics principles and practice (Foley et al) defines the 2 as follows:

Texture mapping can be accomplished in two steps. A simple approach starts by mapping the four corners of the pixel onto the surface. For a bicubic patch this mapping naturally defines a set of points in the surface's (s,t) coordinate space. Next, the pixel's corner points in the surface's (s,t) coordinate space are mapped into the texture's (u,v) coordinate space The four (u,v) points in the texture map define a quadrilateral that approximates the more complex shape into which the pixel may actually map due to surface curvature. We compute a value for the pixel by summing all texels that lie within the quadrilateral, weighting each by the fraction of the texel that lies within the quadrilateral. If a transformed point in (u,v) space falls outside of the texture map, the texture map may e though of as replicated, like the patterns of Section 2.1.3 Rather than always use the identity mapping between (s,t) and (u,v), we can define a correspondence between the four corners of the 0-to-1 (s,t) rectangle and a quadrilateral in (u,v). When the surface is a polygon, it is common to assign texture map coordinates directly to its vertices.

Goz
  • 61,365
  • 24
  • 124
  • 204
  • 1
    Very nice. So there is a difference. Depending on the wrapping move 2 different ST pair can give same UV pair. ST is surface coordinates and UV is texture coordinates once they are wrapped. – Richard Lalancette Feb 16 '14 at 17:16
  • 3
    That is correct. I refer to the OpenGL ES 2.0 spec, section 3.7 on textures. (S, T) are a normalized pair for the fragment. (U, V) can be treated as the texture array width and height in texels. The terms should not be used interchangably. – dturvene Mar 20 '14 at 21:17
8

uv coordinates start from the upper left corner (v-axis is facing down).
st coordinates start from the lower left corner (t-axis is facing up).

s = u;
t = 1-v;

I forgot to tell that textures in opengl should be loaded vertically flipped because the first element of the row data "corresponds to the lower left corner of the texture image" (see glTexImage2D). Only in that case, st and uv coordinates seems to be the same thing.

Bastien Jansen
  • 8,756
  • 2
  • 35
  • 53
shurbsk
  • 121
  • 1
  • 1
  • 10
    I don't think that uv-coordinates start at the upper-left corner. They start at the lower-left corner, as every other coordinate-system in OpenGl too. However, some image-formats store their data starting at the bottom, which forces you to eiter to flip the image, or to pretend that the coordinate-system starts at the upper-left. – maja Apr 21 '14 at 07:52
  • Thanks so much, the `1-v` fixed the issue in my Maya to three.js exporter. :D – kungfooman Feb 25 '16 at 01:25
3

It's a matter of convention.

Autodesk 3D Studio, Alias Maya, NewTek Lightwave and probably others used letters U and V for horizontal and vertical texture coordinates, respectively. DirectX follows the same convention.

Pixar's RenderMan however reserved the letters U and V for parameters in their parametric 3D primitives. So for texturing, they used S and T instead. OpenGL also used this convention for texture coordinates.

So their meaning may be different in theory but, unless you work on some Hollywood movie special effects, they probably both mean texture coordinates.

SnakE
  • 2,355
  • 23
  • 31
2

STQ is the texture coordinate system that must be used used when perspective correction or distortion is required, it relates to the homogeneous texel coordinates uv as follows:

u = (image width in pixels) * S / Q

v = (image height in pixels) * T / Q

When no perspective correction is needed, Q = 1.0, so ST become simply a normalized version of uv, and the difference between them becomes subtle, so some 3D systems skip the uv notation entirely and just use st/STQ for homogeneous/normalized.

Kaaf
  • 350
  • 5
  • 10