Professional Documents
Culture Documents
3D texture mapping
2D texture mapping
Other forms of texture mapping
Lecture 6
Texture mapping
Introduction
Motivation
Motivation
Motivation
Motivation
Linear interpolation
Given two vectors ~a, ~b, linear
interpolation is defined as
Note:
If a, b are scalars and t = 1/2
this is usually refered to as
average ;)
If ~a, ~b are color values (r, g, b),
this gives us a smooth transition
from ~a to ~b
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
3D texture mapping Linear interpolation
2D texture mapping Texture mapping
Other forms of texture mapping
Texture mapping
Adding lots of detail to our models to realistically depict skin,
grass, bark, stone, etc., would increase rendering times
dramatically, even for hardware-supported projective methods.
Texture mapping
Adding lots of detail to our models to realistically depict skin,
grass, bark, stone, etc., would increase rendering times
dramatically, even for hardware-supported projective methods.
Basic idea
Different approaches
3D Object
Different approaches exist,
for example 2D vs. 3D:
2D texture ←→ 3D texture
Outline
1 Introduction
Linear interpolation
Texture mapping
2 3D texture mapping
3D stripe textures
Texture arrays
Solid noise
3 2D texture mapping
Basic idea
Spherical mapping
Triangles
4 Other forms of texture mapping
Bump mapping
Displacement mapping
Environment mapping
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
3D stripe textures
3D texture mapping
Texture arrays
2D texture mapping
Solid noise
Other forms of texture mapping
Texturing 3D objects
f (x, y, z) = c with c ∈ R3
f (xp , yp , zp ) = cp
3D stripe textures
A simple example:
stripes along the X-axis
stripe( xp , yp , zp )
{
if ( sin xp > 0 )
return color0;
else
return color1;
}
}
3D stripe textures
A simple example:
stripes along the X-axis
stripe( xp , yp , zp )
{
if ( sin xp > 0 )
return color0;
else
return color1;
}
}
3D stripe textures
stripe( xp , yp , zp )
{
if ( sin zp > 0)
return color0;
else
return color1;
}
}
3D stripe textures
stripe( xp , yp , zp )
{
if ( sin xp > 0 & sin zp > 0)
return color0;
else
return color1;
}
}
3D stripe textures
Stripes with controllable
width:
3D stripe textures
Texture arrays
Alternatively, we can do an
array lookup in a 3D array
(using all three coordinates of
p for indexing),
or in a 2D array (using only
two coordinates of p).
2D texture arrays
2D texture arrays
2D texture arrays
bxc is the floor function that give the highest integer value ≤ x.
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
3D stripe textures
3D texture mapping
Texture arrays
2D texture mapping
Solid noise
Other forms of texture mapping
Bilinear interpolation
c(u, v) =
(1−u0 )(1−v 0 )cij +u0 (1−v 0 )c(i+1)j +(1−u0 )v 0 ci(j+1) +u0 v 0 c(i+1)(j+1)
Trilinear interpolation
Using 2D arrays with bilinear interpolation is easily extended to
using 3D arrays with trilinear interpolation:
+...
Perlin noise
Goal: create texture with random appearance, but not too random
(e.g., marble patterns, mottled textures as on birds’ eggs)
1st idea: random color at each point
Problem: too much noise, similar to
“white noise” on TV
2nd idea: smoothing of white noise
Problem: bad results and/or
computationally too expensive
3rd idea: create lattice with random
numbers & interpolate between them
Problem: lattice becomes too obvious
Perlin noise makes lattice less obvious by
using three “tricks” . . .
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
3D stripe textures
3D texture mapping
Texture arrays
2D texture mapping
Solid noise
Other forms of texture mapping
Perlin noise
vx = 2ξ − 1
vy = 2ξ 0 − 1
vz = 2ξ 00 − 1
where ξ, ξ 0 , and ξ 00 are random numbers in [0, 1].
Notice that −1 ≤ vi ≤ 1, so we get vectors in the unit cube.
Hashing
Hashing
Hashing
Perlin noise
Hermite interpolation
With our random vectors and hashing function in place, the noise
value n(x, y, z) for a point (x, y, z) is computed as:
where
Ωijk (u, v, w) = ω(u)ω(v)ω(w)(Γijk · (u, v, w))
and
2|t|3 − 3|t|2 + 1 if |t| < 1
ω(t) =
0 otherwise
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
3D stripe textures
3D texture mapping
Texture arrays
2D texture mapping
Solid noise
Other forms of texture mapping
Hermite interpolation
Summary
Perlin noise:
Virtual 3D array &
hashing
Scalar product with
random unit vector
Hermite interpolation
Outline
1 Introduction
Linear interpolation
Texture mapping
2 3D texture mapping
3D stripe textures
Texture arrays
Solid noise
3 2D texture mapping
Basic idea
Spherical mapping
Triangles
4 Other forms of texture mapping
Bump mapping
Displacement mapping
Environment mapping
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
Basic idea
3D texture mapping
Spherical mapping
2D texture mapping
Triangles
Other forms of texture mapping
2D texture mapping
Now let’s look at 2D mapping,
which maps an image onto an
object (cf. wrapping up a gift)
x = xc + r cos φ sin θ
y = yc + r sin φ sin θ
z = zc + r cos θ
θ = arccos z−z
r
c
φ = arctan x−x
y−yc
c
θ = arccos z−z
r
c
φ = arctan x−x
y−yc
c
u = φ mod 2π
2π
v = π−θ
π
Texturing triangles
(0.8, 0.7)
Mapping an image onto a triangle is
done by specifying (u, v) coordinates
for the vertices.
Texturing triangles
Remember that barycentric (0.8, 0.7)
coordinates are very useful for
interpolating over a triangle –
and related textures ;)
Texturing triangles
(0.8, 0.7)
Note that the area and shape of the (0.1, 0.9) (0.6, 0.1)
triangle don’t have to match that of
the mapped triangle.
Texturing triangles
Be careful with perspective, because objects further away appear
smaller, so linear interpolation can lead to artifacts:
MIP-mapping
If viewer is close:
Object gets larger →
Magnify texture
“Perfect” distance:
Not always “perfect” match
(misalignment, etc.)
If viewer is further away:
Object gets smaller → Minify
texture
Problem with minification:
efficiency (esp. when whole
texture is mapped onto one pixel!)
MIP-mapping
Outline
1 Introduction
Linear interpolation
Texture mapping
2 3D texture mapping
3D stripe textures
Texture arrays
Solid noise
3 2D texture mapping
Basic idea
Spherical mapping
Triangles
4 Other forms of texture mapping
Bump mapping
Displacement mapping
Environment mapping
Graphics 2011/2012, 4th quarter Lecture 06: texture mapping
Introduction
Bump mapping
3D texture mapping
Displacement mapping
2D texture mapping
Environment mapping
Other forms of texture mapping
Bump mapping
One of the reasons why we apply
texture mapping:
Real surfaces are hardly flat but
often rough and bumpy. These
bumps cause (slightly) different
reflections of the light.
Bump mapping
Bump mapping
Major problems with bump mapping: silhouettes and shadows
Displacement mapping
Displacement mapping
Environment mapping
Let’s look at image textures again:
Environment mapping
Environment mapping
And now?
In case you didn’t notice: it’s halftime :)
What’s next?
The midterm exam!
Come in time
Bring a pen (no pencil)
Bring your student id
And know the answers ;)
Note: You may not use books, notes, or any electronic equipment
(including cell phones!).
If you ...
... followed the lectures
... read the textbook
... and actively did the
exercises
Important dates