Texture Mapping CS418 Computer Graphics John C. Hart Interpolation - - PowerPoint PPT Presentation

texture mapping
SMART_READER_LITE
LIVE PREVIEW

Texture Mapping CS418 Computer Graphics John C. Hart Interpolation - - PowerPoint PPT Presentation

Texture Mapping CS418 Computer Graphics John C. Hart Interpolation Rasterization will interpolate any vertex 9 attribute across a polygons fragments 8 Interpolating color 7 yields Gouraud smooth 6 shading 5 Can also define


slide-1
SLIDE 1

Texture Mapping

CS418 Computer Graphics John C. Hart

slide-2
SLIDE 2

Interpolation

  • Rasterization will

interpolate any vertex attribute across a polygon’s fragments

  • Interpolating color

yields Gouraud smooth shading

  • Can also define texture

coordinates (u,v) at vertices that, when interpolated, map an image onto a meshed surface

1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9

slide-3
SLIDE 3

Texture Mapping

u v 1 1

slide-4
SLIDE 4

Texture Mapping

u v 1 1

(.2,.6) (.1,.7) .1 .2 .6 .7

slide-5
SLIDE 5

Perspective Correction

  • In this example:

– y = -1, d = 1 and v = -z – vback maps to ytop = -1/-zback – vhalf maps to yhalf = -1/-zhalf – vfront maps to ybottom = -1/-zfront

  • So need to interpolate inverse
  • clip verts + attrs: (x,y,z,w,u,v,1)
  • canvas vertices and attributes:

(x/w, y/w, z/w, 1/w, u/w, v/w)

  • interpolate: (u/w, v/w, 1/w)
  • divide per-pixel by 1/w

to get interpolated (u,v)

(-2,-1,0) (2,-1,0) u = x v = z d ycanvas = y/(-z/d) = y/w z v

zfront zhalf zback vback vhalf vfront ytop

slide-6
SLIDE 6

1 3 5 7 9

Example

(0,0,0) z = -1 y = -1 w = 1 u = 0

  • 3
  • 1

3 .25

  • 5
  • 1

5 .5

  • 7
  • 1

7 .75

  • 9
  • 1

9 1

  • 3
  • 5
  • 9
  • 1

ycanvas = y/(-z/d) = y/w u/w = 0 1/w = 1 u/w = 1/9 1/w = 1/9 u/w = .5/9 1/w = 5/9 u = 1.0 u = 0.1 u = 0.0

slide-7
SLIDE 7

Magnification Aliasing

  • “Jaggies” – lines have a staircased

edge appearance

  • Occur when a single texture sample

(texels) projects to multiple screen pixels

  • (Also occurs when rasterizing lines or

polygon edges)

slide-8
SLIDE 8

Bilinear Filtering

  • “Jaggies” – lines have a staircased

edge appearance

  • Occur when a single texture sample

(texels) projects to multiple screen pixels

  • (Also occurs when rasterizing lines or

polygon edges)

  • Fixed by averaging neighboring

samples to find the value between samples

slide-9
SLIDE 9

Minification Aliasing

  • Many texture pixels (texels) map into a

single screen pixel

  • Cannot simply add them up because

some pixels would take longer than

  • thers to add
slide-10
SLIDE 10

MIP Mapping

  • Many texture pixels (texels) map into a

single screen pixel

  • Cannot simply add them up because

some pixels would take longer than

  • thers to add
  • Create an image pyramid from the

initial texture

  • Each level of the pyramid half the

resolution of the one below it

  • Choose the texture resolution whose

projected texel size most closely matches pixel size