Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Texture mapping
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Perspective correctness=== '''Perspective correct''' texturing accounts for the vertices' positions in 3D space, rather than simply interpolating coordinates in 2D screen space.<ref name="NGen15">{{cite magazine|date=March 1996|title=The Next Generation 1996 Lexicon A to Z: Perspective Correction|url=https://archive.org/details/nextgen-issue-015/page/n39/mode/2up|magazine=[[Next Generation (magazine)|Next Generation]]|publisher=[[Imagine Media]]|issue=15|page=38}}</ref> This achieves the correct visual effect but it is more expensive to calculate.<ref name="NGen15"/> To perform perspective correction of the texture coordinates <math>u</math> and <math>v</math>, with <math>z</math> being the depth component from the viewer's point of view, we can take advantage of the fact that the values <math>\frac{1}{z}</math>, <math>\frac{u}{z}</math>, and <math>\frac{v}{z}</math> are linear in screen space across the surface being textured. In contrast, the original <math>z</math>, <math>u</math> and <math>v</math>, before the division, are not linear across the surface in screen space. We can therefore linearly interpolate these reciprocals across the surface, computing corrected values at each pixel, to result in a perspective correct texture mapping. To do this, we first calculate the reciprocals at each vertex of our geometry (3 points for a triangle). For vertex <math>n</math> we have <math>\frac{u_n}{z_n}, \frac{v_n}{z_n}, \frac{1}{z_n}</math>. Then, we linearly interpolate these reciprocals between the <math>n</math> vertices (e.g., using [[Barycentric coordinate system|barycentric coordinates]]), resulting in interpolated values across the surface. At a given point, this yields the interpolated <math>u_i, v_i</math>, and <math>zReciprocal_i = \frac{1}{z_i}</math>. Note that this <math>u_i, v_i</math> cannot be yet used as our texture coordinates as our division by <math>z</math> altered their coordinate system. To correct back to the <math>u, v</math> space we first calculate the corrected <math>z</math> by again taking the reciprocal <math>z_{correct} = \frac{1}{zReciprocal_i} = \frac{1}{\frac{1}{z_i}}</math>. Then we use this to correct our <math>u_i, v_i</math>: <math>u_{correct} = u_i \cdot z_i</math> and <math> v_{correct} = v_i \cdot z_i</math>.<ref>{{Cite web|url=http://www.lysator.liu.se/~mikaelk/doc/perspectivetexture/|title=Perspective Texturemapping|last=Kalms|first=Mikael|date=1997|website=www.lysator.liu.se|access-date=2020-03-27}}</ref> This correction makes it so that in parts of the polygon that are closer to the viewer the difference from pixel to pixel between texture coordinates is smaller (stretching the texture wider) and in parts that are farther away this difference is larger (compressing the texture). :Affine texture mapping directly interpolates a texture coordinate <math>u^{}_{\alpha}</math> between two endpoints <math>u^{}_0</math> and <math>u^{}_1</math>: ::<math>u^{}_{\alpha}= (1 - \alpha ) u_0 + \alpha u_1</math> where <math>0 \le \alpha \le 1</math> :Perspective correct mapping interpolates after dividing by depth <math>z^{}_{}</math>, then uses its interpolated reciprocal to recover the correct coordinate: ::<math>u^{}_{\alpha}= \frac{ (1 - \alpha ) \frac{ u_0 }{ z_0 } + \alpha \frac{ u_1 }{ z_1 } }{ (1 - \alpha ) \frac{ 1 }{ z_0 } + \alpha \frac{ 1 }{ z_1 } }</math> 3D graphics hardware typically supports perspective correct texturing. Various techniques have evolved for rendering texture mapped geometry into images with different quality/precision trade-offs, which can be applied to both software and hardware. Classic software texture mappers generally did only simple mapping with at most one lighting effect (typically applied through a [[lookup table]]), and the perspective correctness was about 16 times more expensive.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)