Texture Mapping CPSC 453 Fall 2018 Sonny Chan Outline for Today - - PowerPoint PPT Presentation

texture mapping
SMART_READER_LITE
LIVE PREVIEW

Texture Mapping CPSC 453 Fall 2018 Sonny Chan Outline for Today - - PowerPoint PPT Presentation

Texture Mapping CPSC 453 Fall 2018 Sonny Chan Outline for Today & Friday Motivation Texture mapping function Texture sampling Surface properties Motivation Triangle Geometry? 69400 triangles 251 triangles texture


slide-1
SLIDE 1

Texture Mapping

CPSC 453 – Fall 2018 Sonny Chan

slide-2
SLIDE 2

Outline for Today & Friday

  • Motivation
  • Texture mapping function
  • Texture sampling
  • Surface properties
slide-3
SLIDE 3

Motivation

slide-4
SLIDE 4
slide-5
SLIDE 5

Triangle Geometry?

69400 triangles 251 triangles texture mapped

[from M. Tarini et al., Computer Graphics Forum 19(3), 2000]

slide-6
SLIDE 6

Texture mapping is the use of an image to store and render spatially varying surface properties.

slide-7
SLIDE 7

A real world example

  • f a texture mapping problem
slide-8
SLIDE 8

Three Sub-Problems

  • Defining the texture mapping function
  • Looking up the image values: sampling
  • Modifying surface properties
slide-9
SLIDE 9

The Mapping Function

slide-10
SLIDE 10

The Mapping Function

  • Defined from object space to texture space:

φ : S 7! T : (x, y, z) 7! (u, v) φ

slide-11
SLIDE 11

What are the most desirable function

characteristics?

slide-12
SLIDE 12

Which one is best?

slide-13
SLIDE 13

Desirable Characteristics of the Mapping Function

  • Bijectivity: mapping function has inverse
  • Minimal distortion: little stretching or warping
  • Continuity: adjacent positions map to adjacent texels
slide-14
SLIDE 14

Why would we want the function to be

bijective?

slide-15
SLIDE 15

Bijectivity

  • Recall our mapping function:
  • One-to-many: not possible because it’s a function
  • Many-to-one: one texture value has influence on

properties of many surface points

  • One-to-one: ideal for optimal control
  • every surface point maps to a different texture image position

φ : S 7! T : (x, y, z) 7! (u, v)

slide-16
SLIDE 16

Size Distortion

Which is bigger, Australia or Greenland?

slide-17
SLIDE 17

Size Distortion

  • Ideally want the scale of the texture to be roughly

constant across the surface

  • Derivatives of φ should not vary much
  • Level of detail consistent over the object
  • More intuitive to create and interpret the texture
  • Can you think of an instance where you may deliberately

want to have size distortion?

slide-18
SLIDE 18

Shape Distortion

slide-19
SLIDE 19

Shape Distortion

  • A shape (e.g. a circle) drawn on the object surface would

ideally map to the same shape in the texture

  • Derivatives of φ should be similar in all directions
  • More intuitive to create and interpret the texture
slide-20
SLIDE 20

Is it ever possible to have

perfect continuity?

slide-21
SLIDE 21

Continuity

  • Goal is to have a few seams as possible
  • Put seams in inconspicuous places on the model
  • Often a trade-off between other characteristics
slide-22
SLIDE 22

Texture Mapping Functions

  • Parametric surfaces
  • Geometrically determined mappings
  • Planar projection
  • Spherical or cylindrical mapping
  • Manually determined mappings
  • Mapping a single triangle
slide-23
SLIDE 23

What mapping function might suit a

parametric surface?

slide-24
SLIDE 24

How do we parameterize

a sphere?

slide-25
SLIDE 25

Which map do we use?

slide-26
SLIDE 26

Planar Projection

φ(x, y, z) = (x, y)

  • r

u = x v = y

slide-27
SLIDE 27

Characteristics of Planar Projection

slide-28
SLIDE 28

Spherical Coordinates

Works well for “sphere-ish” objects

φ(x, y, z) =  

π+tan1( y

x)

2π π−cos1(

z kxk)

π

 

slide-29
SLIDE 29

Non-spherical objects?

slide-30
SLIDE 30

Cylindrical Coordinates

φ(x, y, z) = " π+tan−1( y

x)

2π 1+z 2

#

slide-31
SLIDE 31

Complex Shapes

What mapping function would we use for an object such as this?

[from crossofthedutchman.com]

slide-32
SLIDE 32

Hand-Crafted

[from crossofthedutchman.com]

slide-33
SLIDE 33

The Final Mapping

Can you spot the seams?

slide-34
SLIDE 34

Texturing a Triangle

What mapping function do we use?

slide-35
SLIDE 35

Barycentric Coordinates

p0 p1 p2 f(u, v) = (1 − u − v)p0 + up1 + vp2 u

v

w

(.6, .4, 0) (.3, .2, .5)

slide-36
SLIDE 36

Barycentric Mapping

p0 p1

(.3, .2, .5)

p2

A0 A1 A2

t0 = (.2, .2) t1 = (.8, .4) t2 = (.4, .8)

(u, v) = 0.5 t0 + 0.3 t1 + 0.2 t2

slide-37
SLIDE 37

Texture-Mapped Triangle

slide-38
SLIDE 38

Mapping Function Summary

  • Goal is to define a function from the object to the image
  • ideally continuous, bijective, and minimizes distortion
  • Standard mapping functions sometimes work well
  • planar projection, spherical mapping, cylindrical mapping
  • Complex objects often require hand-crafted functions
  • Barycentric coordinates are used to interpolate texture

values across individual triangles

slide-39
SLIDE 39

Texture Sampling

reading our values…

slide-40
SLIDE 40

What is that setting,

anisotropic filtering?

slide-41
SLIDE 41

What does this setting do?

(Borderlands 2, 2K Games)

slide-42
SLIDE 42

Texture Footprint: Texel to Pixel Ratio

φ φ rendered image texture map Are the texels larger or smaller than the pixels?

slide-43
SLIDE 43

Texture Magnification

  • ne texel → many pixels

What is our main challenge?

slide-44
SLIDE 44

Image Reconstruction: An Interpolation Problem

nearest linear sinc

slide-45
SLIDE 45

Texture Minification

many texels → one pixel What is our main challenge?

slide-46
SLIDE 46
slide-47
SLIDE 47

1 2 3 4 5 6 7 8 9 10 11

  • 1

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

  • 1

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

  • 1

1

Aliasing!!! 🙂

slide-48
SLIDE 48

Anti-Aliasing Textures

How do we do it?

No jaggies!

slide-49
SLIDE 49

Anti-Aliasing Textures

How do we do it?

No jaggies!

slide-50
SLIDE 50

How much do we blur?

slide-51
SLIDE 51

Texture Filtering

How many texture image pixels does this screen pixel cover?

[from johnwhigham.blogspot.ca]

slide-52
SLIDE 52

Mipmaps

  • multum in parvo
  • Construct layers, each half

the size of the previous, to form an image pyramid

  • Choose pyramid level

depending on footprint

  • What is the highest

frequency content of each level?

slide-53
SLIDE 53

Revisiting the Texture Footprint

mipmap sampling

slide-54
SLIDE 54

Anisotropic Filtering

4x anisotropic filtering

slide-55
SLIDE 55

Texture Sampling/Filtering Summary

  • Must choose the right strategy depending on the pixel!
slide-56
SLIDE 56

Texture Sampling/Filtering Summary

  • Must choose the right strategy depending on the pixel!
  • Magnification is an interpolation problem
  • Magnification is an anti-aliasing problem
slide-57
SLIDE 57

Surface Properties

What can we texture map?

slide-58
SLIDE 58

Our heuristic shading equation from last week…

  • with ambient, diffuse, and specular terms:
  • cr is reflectance (diffuse) colour of material
  • cp is specular colour of material
  • p is Phong exponent, or shininess of material
  • cl is light source intensity (colour)
  • ca is ambient light intensity (colour)

c = cr ⇣ ca + cl max(0, ˆ n ·ˆ l) ⌘ + cl cp ⇣ ˆ h · ˆ n ⌘p

slide-59
SLIDE 59

Colour or Diffuse Maps

slide-60
SLIDE 60

Specular Maps

slide-61
SLIDE 61

Specular Maps

[from kay-vriend.blogspot.ca]

slide-62
SLIDE 62

Normal Maps

[from kay-vriend.blogspot.ca]

slide-63
SLIDE 63

Bump Maps

[from kay-vriend.blogspot.ca]

slide-64
SLIDE 64

Bump Maps

slide-65
SLIDE 65

Light Maps

Quake 2, id software

slide-66
SLIDE 66

Light Maps

slide-67
SLIDE 67

Rendered Result

Putting all the maps together…

slide-68
SLIDE 68

Rendered Result

Oops, did we break the illusion?

slide-69
SLIDE 69

Things to Remember

  • Texture mapping involves defining a mapping function,

sampling the image, and applying the texture values

  • Mapping functions balance bijectivity, continuity, and

minimizing distortion

  • Interpolation and anti-aliasing play an important role in

high-quality texture sampling

  • Texture mapping can be used to modify any surface

property that appears in our lighting equation!