Texture Mapping
CPSC 453 – Fall 2018 Sonny Chan
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
Texture Mapping
CPSC 453 – Fall 2018 Sonny Chan
Outline for Today & Friday
Motivation
Triangle Geometry?
69400 triangles 251 triangles texture mapped
[from M. Tarini et al., Computer Graphics Forum 19(3), 2000]
Texture mapping is the use of an image to store and render spatially varying surface properties.
A real world example
Three Sub-Problems
The Mapping Function
The Mapping Function
φ : S 7! T : (x, y, z) 7! (u, v) φ
What are the most desirable function
Which one is best?
Desirable Characteristics of the Mapping Function
Why would we want the function to be
Bijectivity
properties of many surface points
φ : S 7! T : (x, y, z) 7! (u, v)
Size Distortion
Which is bigger, Australia or Greenland?
Size Distortion
constant across the surface
want to have size distortion?
Shape Distortion
Shape Distortion
ideally map to the same shape in the texture
Is it ever possible to have
Continuity
Texture Mapping Functions
What mapping function might suit a
How do we parameterize
Which map do we use?
Planar Projection
φ(x, y, z) = (x, y)
u = x v = y
Characteristics of Planar Projection
Spherical Coordinates
Works well for “sphere-ish” objects
φ(x, y, z) =
π+tan1( y
x)
2π π−cos1(
z kxk)
π
Non-spherical objects?
Cylindrical Coordinates
φ(x, y, z) = " π+tan−1( y
x)
2π 1+z 2
#
Complex Shapes
What mapping function would we use for an object such as this?
[from crossofthedutchman.com]
Hand-Crafted
[from crossofthedutchman.com]
The Final Mapping
Can you spot the seams?
Texturing a Triangle
What mapping function do we use?
Barycentric Coordinates
p0 p1 p2 f(u, v) = (1 − u − v)p0 + up1 + vp2 u
v
w
(.6, .4, 0) (.3, .2, .5)
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
Texture-Mapped Triangle
Mapping Function Summary
values across individual triangles
Texture Sampling
reading our values…
What is that setting,
What does this setting do?
(Borderlands 2, 2K Games)
Texture Footprint: Texel to Pixel Ratio
φ φ rendered image texture map Are the texels larger or smaller than the pixels?
Texture Magnification
What is our main challenge?
Image Reconstruction: An Interpolation Problem
nearest linear sinc
Texture Minification
many texels → one pixel What is our main challenge?
1 2 3 4 5 6 7 8 9 10 11
1 1 2 3 4 5 6 7 8 9 10 11
1 1 2 3 4 5 6 7 8 9 10 11
1
Anti-Aliasing Textures
How do we do it?
Anti-Aliasing Textures
How do we do it?
Texture Filtering
How many texture image pixels does this screen pixel cover?
[from johnwhigham.blogspot.ca]
Mipmaps
the size of the previous, to form an image pyramid
depending on footprint
frequency content of each level?
Revisiting the Texture Footprint
mipmap sampling
Anisotropic Filtering
4x anisotropic filtering
Texture Sampling/Filtering Summary
Texture Sampling/Filtering Summary
Surface Properties
What can we texture map?
Our heuristic shading equation from last week…
c = cr ⇣ ca + cl max(0, ˆ n ·ˆ l) ⌘ + cl cp ⇣ ˆ h · ˆ n ⌘p
Colour or Diffuse Maps
Specular Maps
Specular Maps
[from kay-vriend.blogspot.ca]
Normal Maps
[from kay-vriend.blogspot.ca]
Bump Maps
[from kay-vriend.blogspot.ca]
Bump Maps
Light Maps
Quake 2, id software
Light Maps
Rendered Result
Putting all the maps together…
Rendered Result
Oops, did we break the illusion?
Things to Remember
sampling the image, and applying the texture values
minimizing distortion
high-quality texture sampling
property that appears in our lighting equation!