Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Texture Mapping
Greg Humphreys
CS445: Intro Graphics Texture
Image
Surface
University of Virginia, Fall 2004
“Pixels”
“Texels”
Angel Figure 9.3
3D World Coordinates
Viewing
Transformation
3D Camera Coordinates
Projection
Transformation
2D Screen Coordinates
Clipping
2D Screen Coordinates
Viewport Texture mapping With surface texture
Transformation
2D Image Coordinates
Scan
Conversion
2D Image Coordinates
Polygonal model
Image
+ =
geometry image texture map
1
Option: Varieties of projections Option: unfold the surface
[Piponi2000]
[Paul Bourke]
[Sander2001]
2
Texture Mapping Texture Mapping
• When scan convert, map from … • Texture mapping is a 2D projective transformation
image coordinate system (x,y) to texture coordinate system: (t,s) to
modeling coordinate system (u,v) to image coordinate system (x,y)
texture image (t,s)
(1,1)
(0,1)
t v (1,0) y
s u x
(0,0)
3
Interpolating Parameters Perspective-Correct Interpolation
• Perspective foreshortening is not getting applied to • Skipping a bit of math to make a long story short…
our interpolated parameters Rather than interpolating u and v directly, interpolate u/z
Parameters should be compressed with distance and v/z
Linearly interpolating them in screen-space doesn’t do this » These do interpolate correctly in screen space
» Also need to interpolate z and multiply per-pixel
• Is this a problem with Gouraud shading? Problem: we don’t know z anymore
• A: It can be, but we usually don’t notice (why?) Solution: we do know w ∝ 1/z
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide17.html So…interpolate uw and vw and w, and compute
u = uw/w and v = vw/w for each pixel
» This unfortunately involves a divide per pixel (Just 1?)
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide14.html
4
Mip Maps MIP-map Example
• Keep textures prefiltered at multiple resolutions
For each pixel, linearly interpolate between
two closest levels (e.g., trilinear filtering) • No filtering:
Fast, easy for hardware
AAAAAAAGH
MY EYES ARE BURNING
• MIP-map texturing:
S1
S2
Mapping
Filtering
I = T ( s, t )( I E + K A I A + ! L ( K D ( N • L) + K S (V • R ) n ) S L I L + K T I T + K S I S )
5
Texture Mapping Variations Bump Mapping
• A texture can modulate any parameter in the Phong • Texture = change in surface normal!
lighting equation
Texture as
Texture as
diffuse lighting
R,G,B:
coefficients: Sphere w/ diffuse texture
Sphere w/ diffuse texture Swirly bump map
and swirly bump map
+ =
• How can you tell a bumped-mapped object from an
object in which the geometry is explicitly modeled?
Light map
6
Solid textures Procedural Texture
7
8