java UV 和 ST 纹理坐标之间的差异
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10568390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between U V and S T texture coordinates
提问by Nabmeister
What's the difference between a U V texture coordinate vs. S T texture Coordinate?
UV 纹理坐标与 ST 纹理坐标之间有什么区别?
I know that U V and S T are used in OpenGL.
我知道在 OpenGL 中使用了 UV 和 ST。
I also know that S T are also used in Java.
我也知道在 Java 中也使用了 ST。
回答by Goz
Computer graphics principles and practice (Foley et al)defines the 2 as follows:
计算机图形学原理和实践(Foley 等人)将这两个定义如下:
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.
纹理映射可以分两步完成。一种简单的方法是将像素的四个角映射到表面上。对于双三次面片,该映射自然地定义了表面 (s,t) 坐标空间中的一组点。接下来,将像素在表面 (s,t) 坐标空间中的角点映射到纹理的 (u,v) 坐标空间纹理图中的四个 (u,v) 点定义了一个四边形,将更复杂的形状近似为由于表面曲率,像素可能实际映射。我们通过对位于四边形内的所有纹素求和来计算像素的值,并通过位于四边形内的纹素的分数对每个纹素进行加权。如果 (u,v) 空间中的变换点落在纹理贴图之外, 当表面是多边形时,通常将纹理贴图坐标直接分配给它的顶点。
回答by Tim
They mean the same thing, it's just a different naming convention.
它们的意思相同,只是命名约定不同。
U = S = x dimension
V = T = y dimension
回答by shurbsk
uvcoordinates start from the upper leftcorner (v-axis is facing down).
stcoordinates start from the lower leftcorner (t-axis is facing up).
UV坐标从开始左上角(v轴朝下)。
ST坐标从开始左下角(叔轴朝上)。
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.
我忘了告诉 opengl 中的纹理应该垂直翻转加载,因为行数据的第一个元素“对应于纹理图像的左下角” (参见 glTexImage2D)。只有在这种情况下,st 和 uv 坐标似乎是一回事。
回答by SnakE
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. DirectXfollows the same convention.
Autodesk 3D Studio、Alias Maya、NewTek Lightwave 和其他可能使用字母 U 和 V 分别表示水平和垂直纹理坐标的公司。 DirectX遵循相同的约定。
Pixar's RenderMan however reserved the letters U and V for parameters in their parametric 3D primitives. So for texturing, they used S and Tinstead. OpenGL also used this convention for texture coordinates.
然而,皮克斯的 RenderMan 保留了字母 U 和 V 作为参数 3D 基元中的参数。所以对于纹理,他们使用S 和 T代替。OpenGL 也将这个约定用于纹理坐标。
So their meaning may be different in theory but, unless you work on some Hollywood movie special effects, they probably both mean texture coordinates.
因此,它们的含义在理论上可能有所不同,但除非您制作某些好莱坞电影特效,否则它们可能都表示纹理坐标。
回答by Kaaf
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:
STQ是需要透视校正或畸变时必须使用的纹理坐标系,它与同构texel坐标uv的关系如下:
u = (image width in pixels) * S / Q
u =(以像素为单位的图像宽度)* S / Q
v = (image height in pixels) * T / Q
v =(以像素为单位的图像高度)* 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.
当不需要透视校正时,Q = 1.0,所以 ST 就变成了 uv 的一个归一化版本,它们之间的差异变得微妙,所以一些 3D 系统完全跳过了 uv 表示法,只使用 st/STQ 进行均质/归一化。