Difference between UV and ST texture coordinates
Asked Answered
S

6

28

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.

Sexlimited answered 13/5, 2012 at 0:8 Comment(2)
"I know that U V and S T are used in opengl" There is no place in the OpenGL specification that ever refers to UV.Analog
@NicolBolas There is, for instance equation 8.7 in the OpenGL 4.3 spec.Levorotatory
W
39

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

U = S = x dimension
V = T = y dimension
Wretched answered 13/5, 2012 at 0:12 Comment(8)
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.Irreligion
@Irreligion never heard of this. Can you cite a source?Trenna
@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 (research.microsoft.com/apps/pubs/default.aspx?id=73939).Irreligion
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.Levorotatory
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.Frith
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)Fugate
I may be wrong but S T is used for 2 dimensional textures, and UV are additional ones for 3d and 4d texturesStrow
T - top, S - sidePhony
C
36

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.

Culicid answered 29/11, 2012 at 9:31 Comment(2)
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.Frith
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.Beaman
P
9

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.

Peptone answered 16/4, 2013 at 15:38 Comment(2)
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.Gaptoothed
Thanks so much, the 1-v fixed the issue in my Maya to three.js exporter. :DJurado
C
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.

Costermonger answered 4/11, 2012 at 15:30 Comment(0)
W
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.

Wordage answered 4/3, 2019 at 3:11 Comment(0)
S
0

although there are often other interpretations, generally ST coords are inherent to the geometry of the primitive and UVs are authored and edited by hand. Typically, each primitive has it's own ST coords, and entire meshes of prims have UV coords. Early books such as "Foley & Van Dam" had the exact opposite usage with ST being hand authored, but the industry adopted UV as the authored parameter naming convention.

Stet answered 4/4, 2024 at 18:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.