Sei sulla pagina 1di 8

Textures

• Describe color variation in interior of 3D polygon


 When scan converting a polygon, vary pixel colors
according to values fetched from a texture

Texture Mapping
Greg Humphreys
CS445: Intro Graphics Texture
Image
Surface
University of Virginia, Fall 2004
“Pixels”
“Texels”
Angel Figure 9.3

3D Rendering Pipeline (for direct illumination) Surface Textures


3D Primitives • Add visual detail to surfaces of 3D objects
3D Modeling Coordinates
Modeling
Transformation
3D World Coordinates
Lighting

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

Surface Textures Parameterization


• Add visual detail to surfaces of 3D objects

+ =
geometry image texture map

• Q: How do we decide where on the geometry


each color from the image should go?
[Daren Horley]

1
Option: Varieties of projections Option: unfold the surface

[Piponi2000]

[Paul Bourke]

Option: make an atlas Option: it’s the artist’s problem

charts atlas surface

[Sander2001]

Overview Texture Mapping


• Texture mapping methods • Steps:
 Parameterization  Define texture
 Mapping  Specify mapping from texture to surface
 Filtering  Lookup texture values during scan conversion
• Texture mapping applications
 Modulation textures
 Illumination mapping (0,1)
 Bump mapping
 Environment mapping
 Image-based rendering t v (1,0) y
 Volume textures s u x
(0,0)
 Non-photorealistic rendering
Texture Modeling Image
Coordinate Coordinate Coordinate
System System System

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)

Texture Modeling Image


Coordinate Coordinate Coordinate
System System System Allison Klein, Princeton

Naïve Texture Mapping Naïve Texturing Artifacts


• A first cut at a texture-mapping rasterizer: • Warping at edges of triangles
 For each pixel:
» Interpolate u & v down edges and across spans
• A more obvious example:
» Look up nearest texel in texture map
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html
» Color pixel according to texel color (possibly modulated
by lighting calculations)
 McMillan’s demo of this is at
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide05.html • Consider the geometry of interpolating parameters
 What artifacts do you see in this demo?
more carefully

Interpolating Parameters Texture Mapping


• The problem turns out to be fundamental to
interpolating parameters in screen-space
 Uniform steps in screen space ≠ uniform steps in world space

Linear interpolation Correct interpolation


of texture coordinates with perspective divide
Hill Figure 8.42

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

Overview Texture Filtering


• Texture mapping methods • Must sample texture to determine color
 Parameterization at each pixel in image
 Mapping
 Filtering

• Texture mapping applications


 Modulation textures
 Illumination mapping
 Bump mapping
 Environment mapping
 Image-based rendering
 Non-photorealistic rendering

Angel Figure 9.4

Texture Map Aliasing Texture Filtering


• Naive texture mapping aliases badly • Size of filter depends on projective warp
 Can prefilter images
• Look familiar?
int uval = (int) (u * denom + 0.5f); » Mip maps
int vval = (int) (v * denom + 0.5f);
int pix = texture.getPixel(uval, vval); » Summed area tables

• Actually, each pixel maps to a region in texture


 |PIX| < |TEX|
» Easy: interpolate (bilinear) between texel values
 |PIX| > |TEX|
» Hard: average the contribution from multiple texels
 |PIX| ~ |TEX|
Magnification Minification
» Still need interpolation!

Angel Figure 9.14

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:

• Why “Mip” maps? Where are my glasses?

Summed-area tables Summed-Area Tables


• At each texel keep sum of all values down & right • Mipmaps assume that each pixel projects to a
 To compute sum of all values within a rectangle, square in the texture (which is a lie)
do two subtracts and an add
 Better ability to capture very oblique projections • SAT can integrate texels covered by the pixel more
 But, cannot store values in a single byte exactly (but still quickly)
• Example:

S1

S2

MIP-map texturing Summed-area table texturing

Overview Modulation textures


• Texture mapping methods Map texture values to scale factor
 Parameterization
Wood texture

 Mapping
 Filtering

• Texture mapping applications


 Modulation textures
 Illumination mapping
 Bump mapping
 Environment mapping
 Image-based rendering Texture
 Non-photorealistic rendering value

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

More Bump Mapping Displacement Mapping

+ =
• How can you tell a bumped-mapped object from an
object in which the geometry is explicitly modeled?

Illumination Maps Environment Maps

• Quake introduced illumination maps or light maps to


capture lighting effects in video games
Texture map:

Light map

Images from Illumination and Reflection Maps:


Texture map Simulated Objects in Simulated and Real Environments
Gene Miller and C. Robert Hoffman
+ light map: SIGGRAPH 1984 “Advanced Computer Graphics Animation” Course Notes

6
Solid textures Procedural Texture

Texture values indexed


by 3D location (x,y,z)
• Expensive storage, or
• Compute on the fly,
e.g. Perlin noise 

Procedural Texture Gallery

7
8

Potrebbero piacerti anche