Professional Documents
Culture Documents
Computer Graphics The Problem:: Some Slides Adopted From H. Pfister, Harvard
Computer Graphics The Problem:: Some Slides Adopted From H. Pfister, Harvard
Lecture 7:
Texture mapping
1
Texture Definition Procedural textures
• non-intuitive
• difficult to match existing texture
2
Texture mapping: Terminology The concept of texture mapping
3
Texture synthesis Texture coordinates
(0,0) (1,0)
4
Perspective projection How to fix?
• The problem is that perspective projection does not preserve • Suppose we assign parameter t to vertices p and r
affine combinations of points!
• In particular, equal distances along a line in eye space do not • Suppose t = 0 at p, and t = 1 at r
map to equal distances in screen space • p projects to p’ and r projects to r’ (divide by w)
• What value should t have at location q’?
p
p’ = p/wp
q’ = q/wq q
• Linear interpolation in screen space is not equal to linear
interpolation in eye space!
r’r’==r/z
r/w
r r
r
• We cannot linearly interpolate t between p’ and r’ • Linearly interpolate t / w (not t) between p’ and r’.
• Only projected values can be linearly interpolated in – Compute tp’ = tp / wp and tr’ = tr / wr
screen space – Linearly interpolate (lerp) tp’ and tr’ to get tq’ at location q’
• Solution: perspective-correct interpolation • But, we want the (unprojected) parameter tq, not tq’
p p
p’ = p/wp p’ = p/wp
q’ = q/wq q’ = q/wq
q q
r’r’==r/z
r/w
r r r’r’==r/z
r/w
r r
r r
Graphics Lecture 5: Slide 19
5
Perspective Correct Interpolation Perspective Correct Interpolation
r’r’==r/z
r/w
r r
r
P2 Diagram 7.2
Bi-linear texture
e
map
c
b
p
β Polygon being
textured
a
P4
P1 α
6
Bi-linear Map - Solving for α and β Non Linearities in texture mapping
• Texture mapping can be used to alter some or all of • Increases the apparent complexity of simple geometry
the constants in the illumination equation • Requires perspective projection correction
• Can specify
variations in
(
L(ω r ) = k a + k d (n ⋅ l) + ks (v ⋅ r) q ) 4Φπ d s
2
shading within
a primitive:
– Illumination
– Surface
Reflectance
€
Constant Diffuse Color Diffuse Texture Color Texture used as Label Texture used as Diffuse Color
7
What's Missing? Remember Normal Averaging for Shading?
• What's the difference between a real brick • Instead of using the normal of the triangle, interpolate an averaged
wall and a photograph of the normal at each vertex across the face
wall texture-mapped onto a plane?
• What happens
if we change
the lighting or
the camera
position?
• Textures can be used to alter the surface normal of an object. • The texture map is treated as a single-valued height
• This does not change the actual shape of the surface - we are function.
only shading it as if it were a different shape!
• The partial derivatives of the texture tell us how to
alter the true surface normal at each point to make the
object appear as if it were deformed by the height
function.
Sphere w/Diffuse Texture Swirly Bump Map Sphere w/Diffuse Texture & Bump Map
8
Another Bump Map Example What's Missing?
Cylinder w/Diffuse Texture Map Cylinder w/Texture Map & Bump Map
• Use the texture map to actually move the surface point. • We can simulate reflections by using the direction of the
– How is this different than bump mapping? reflected ray to index a spherical texture map at "infinity".
• The geometry must be displaced before visibility is • Assumes that all reflected rays begin from the same point.
determined.
9
Environment Mapping Example Questions?
10