Docsity

Texture Mapping - Lecture Slides | CS 5501, Study notes of Computer Science

Toggle sidebar
bg1
1
DavidLuebke 5/6/2000
CS 551 / 645:
Introductory Computer Graphics
Texture Mapping II
DavidLuebke 5/6/2000
Administrivia
●Assignment 5: justkidding
DavidLuebke 5/6/2000
Recap: Texture Mapping
●Adding surface detail helps keep CG images
from looking simple and sterile
●Explicitly modeling this detail in geometry can
be very expensive
– Zebra stripes, wood grain, writing on a whiteboard
●Texture mapping pastes images onto the
surfaces in the scene, adding realistic fine
detail without exploding the geometry
DavidLuebke 5/6/2000
Recap: Texture Mapping
Recap: Texture Mapping
DavidLuebke 5/6/2000
Recap: Texture Coordinates
●Give each vertex of the triangle a
texture
coordinate
(u, v)
●For other points on the triangle, interpolate
texture coordinate from the vertices
●Problem: interpolating in screen-space (a la
Gouraud shading) is
incorrect
– Perspective foreshortening should compress the
texture image on distant regions of the surface
–Demoat
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html
pf3
pf4
pf5

Partial preview of the text

Download Texture Mapping - Lecture Slides | CS 5501 and more Study notes Computer Science in PDF only on Docsity!

David Luebke 5/6/

CS 551 / 645:

Introductory Computer Graphics

Texture Mapping II

David Luebke 5/6/

Administrivia

l Assignment 5: just kidding

David Luebke 5/6/

Recap: Texture Mapping

l Adding surface detail helps keep CG images

from looking simple and sterile

l Explicitly modeling this detail in geometry can

be very expensive

  • Zebra stripes, wood grain, writing on a whiteboard

l Texture mapping pastes images onto the

surfaces in the scene, adding realistic fine

detail without exploding the geometry

David Luebke 5/6/

Recap: Texture Mapping

Recap: Texture Mapping

David Luebke 5/6/

Recap: Texture Coordinates

l Give each vertex of the triangle atexture

coordinate ( u, v )

l For other points on the triangle, interpolate

texture coordinate from the vertices

l Problem: interpolating in screen-space (a la

Gouraud shading) isincorrect

  • Perspective foreshortening should compress the texture image on distant regions of the surface
  • Demo at http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html

David Luebke 5/6/

Recap: Perspective-Correct

Interpolation

l Skipping some math…

  • Rather than interpolating u and v directly, interpolate u/z and v/z n These do interpolate correctly in screen space n Also need to interpolate z and multiply per-pixel
  • Problem: we don’t know z anymore
  • Solution: we do know w ≈ 1/z
  • So…interpolate uw and vw and w , and compute u = uw/w and v = vw/w for each pixel n This unfortunately involves a divide per pixel

David Luebke 5/6/

Recap: Texture Map Aliasing

l Naive texture mapping looks blocky, pixelated

  • Problem: using a single texel to color each pixel: int uval = (int) (u * denom + 0.5f); int vval = (int) (v * denom + 0.5f); int pix = texture.getPixel(uval, vval);
  • Actually, each pixel maps to a region in texture n If the pixel is larger than a texel, we should average the contribution from multiple texels somehow n If the pixel is smaller than a texel, we should interpolate between texel values somehow n Even if pixel size ≈ texel size, a pixel will in general fall between four texels
  • An example of a general problem calledaliasing

David Luebke 5/6/

Recap: Texture Map Antialiasing

l Usebilinear interpolation to average nearby

texel values into a single pixel value (Draw it)

  • Find 4 nearest texture samples n Round u & v up and down
  • Interpolate texel values in u
  • Interpolate resulting values in v

l Also addresses the problem of many pixels

projecting to a single texel (Why?)

David Luebke 5/6/

Recap: Texture Map Antialiasing

l What if a single pixel covers many texels?

  • Problem: sampling those texels at a single point (the center of the pixel): n Produces Moire patterns in coherent texture (checkers) n Leads to flicker ortexture crawling as the texture moves
  • Approach: blur the image under the pixel, averaging the contributions of the covered texels n But calculating which texels every pixel covers is way too expensive, especially as the texture is compressed
  • Solution: pre-calculate lower-resolution versions of the texture that incorporate this averaging

David Luebke 5/6/

MIP-maps

l For a texture of 2n^ x 2n^ pixels, compute n-

textures, each at ½ the resolution of previous:

l This multiresolution texture is called aMIP-map

Original Texture Lower Resolution Versions

David Luebke 5/6/

Generating MIP-maps

l Generating a MIP-map from a texture is easy

  • For each texel in level i , average the values of the four corresponding texels in level i -

l If a texture requires n bytes of storage, how

much storage will a MIP-map require?

l Answer: 4n/

David Luebke 5/6/

MIP-maps and Signal Processing

l An aside: aliasing and antialiasing are

properly topics insampling theory

  • Nyquist theorem, convolution and reconstruction, filters and filter widths
  • Textures are particularly difficult because a tiled texture can easily generate infinite frequencies n E.g., a checkered plane receding to an infinite horizon
  • Using a MIP-map amounts toprefiltering the texture image to reduce artifacts caused by sampling at too low a rate

David Luebke 5/6/

Summed-Area Tables

l A technique calledsummed-area tables lets

us integrate texels covered by the pixel more

exactly (but still quickly)

  • Details in the book

l Example:

MIP-map texturing Summed-area table texturing

David Luebke 5/6/

Texture Mapping Variations

l A texture can modulate any parameter in the

rendering process:

å^ (^ )^ (^ )

÷ 

  

= +  ⋅ + ⋅

lights

i

n total a ambient i d s

shiny I kI I k N L k V R

1

ˆ ˆ ˆ ˆ

Texture as R,G,B:

Texture as diffuse lighting coefficients:

David Luebke 5/6/

Bump Mapping

l The texture map can even modulate the

surface normal used for shading

Sphere w/ diffuse texture Swirly bump map Sphere w/ diffuse textureand swirly bump map

  • =

More Bump Mapping

l How can you tell a bumped-mapped object from an object in which the geometry is explicitly modeled? David Luebke 5/6/

Last Bump Mapping Example

David Luebke 5/6/

Displacement Map

l Adisplacement map actually displaces the

geometry

  • Treats the texture as a height field to be applied to the surface
  • Hard to do in interactive graphics pipeline
  • But doable in ray tracing

David Luebke 5/6/

Displacement Map Example

l What is the fundamental difference between

displacement mapping and bump mapping?

David Luebke 5/6/

Illumination Maps

l Quake usesillumination maps orlight maps to capture lighting effects: Texture map:

Texture map

  • light map:

Light map

David Luebke 5/6/

Illumination Maps

l Illumination maps differ from texture maps in

that they:

  • Usually apply to only a single surface
  • Are usually fairly low resolution
  • Usually capture just intensity (1 value) rather than color (3 values)

l Illumination maps can be:

  • Painted by hand: Disney’s Aladdin ride
  • Calculated by a global illumination process: Nintendo64 demo

l Origin of the idea

David Luebke 5/6/

Other Texture Applications

l Lots of other interesting applications of the

texture-map concept:

  • Shadow maps
  • 3-D textures (marble, wood, clouds)
  • Chrome maps
  • Procedural textures

l For a neat explanation of the first two (with

cool applets, as usual) check out:

http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture22/Slide21.html