Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003)...
-
Upload
garry-morton -
Category
Documents
-
view
212 -
download
0
Transcript of Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003)...
![Page 1: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/1.jpg)
Texture Mapping
May 4, 2006
![Page 2: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/2.jpg)
Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught
by Leonard McMillan http://www.unc.edu/courses/2003spring/comp/236/001/handouts.html
![Page 3: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/3.jpg)
![Page 4: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/4.jpg)
![Page 5: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/5.jpg)
![Page 6: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/6.jpg)
![Page 7: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/7.jpg)
![Page 8: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/8.jpg)
![Page 9: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/9.jpg)
![Page 10: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/10.jpg)
![Page 11: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/11.jpg)
![Page 12: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/12.jpg)
![Page 13: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/13.jpg)
![Page 14: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/14.jpg)
Compare the above with what we discussed previously…
(Note the different meaning of s and t.)
![Page 15: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/15.jpg)
Derivation of s and t
• Two end points P1=(x1, y1, z1) and P2=(x2, y2, z2). Let P3=(1-t)P1+(t)P2
• After projection, P1, P2, P3 are projected to (x’1, y’1), (x’2, y’2), (x’3, y’3) in screen coordinates. Let (x’3, y’3)=(1-s)(x’1, y’1) + s(x’2, y’2).
![Page 16: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/16.jpg)
• (x’1, y’1), (x’2, y’2), (x’3, y’3) are obtained from P1, P2, P3 by:
)
11
)1((
1
'
'
'
1
'
'
'
,
1
'
'
'
2
2
2
1
1
1
3
3
3
3
33
33
33
2
2
2
2
22
22
22
1
1
1
1
11
11
11
z
y
x
tz
y
x
tMz
y
x
M
w
wz
wy
wx
z
y
x
M
w
wz
wy
wx
z
y
x
M
w
wz
wy
wx
![Page 17: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/17.jpg)
Since
We have:
2
22
22
22
2
2
2
1
11
11
11
1
1
1
'
'
'
1
,'
'
'
1 w
wz
wy
wx
z
y
x
M
w
wz
wy
wx
z
y
x
M
2
22
22
22
1
11
11
11
2
2
2
1
1
1
3
33
33
33
'
'
'
'
'
'
)1(
11
)1('
'
'
w
wz
wy
wx
t
w
wz
wy
wx
t
z
y
x
Mtz
y
x
Mt
w
wz
wy
wx
![Page 18: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/18.jpg)
When P3 is projected to the screen, we get (x’3, y’3) by dividing by w, so:
But remember that
(x’3, y’3)=(1-s)(x’1, y’1) + s(x’2, y’2)
Looking at x coordinate, we have
))1(
'')1(,
)1(
'')1(()','(
21
2211
21
221133 wtwt
wytwyt
wtwt
wxtwxtyx
21
221121 )1(
'')1()1(
wtwt
wxtwxtxsxs
![Page 19: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/19.jpg)
We may rewrite s in terms of t, w1, w2, x’1, and x’2.
In fact,
or conversely
Surprisingly, x’1 and x’2 disappear.
)()1( 121
2
21
2
wwtw
wt
wtwt
wts
221
1
21
1
)()1( wwws
ws
wsws
wst
![Page 20: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/20.jpg)
Texture Mapping II
![Page 21: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/21.jpg)
What You Will Learn Today?
• Bump maps
• Mipmapping for antialiased textures
• Projective trextures
• Shadow maps
• Environment maps
![Page 22: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/22.jpg)
The Limits of Geometric Modeling
•Although graphics cards can render over 10 million polygons per second, that number is insufficient for many phenomena–Clouds–Grass–Terrain–Skin
![Page 23: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/23.jpg)
Modeling an Orange•Consider the problem of modeling an orange (the fruit)
•Start with an orange-colored sphere–Too simple
•Replace sphere with a more complex shape–Does not capture surface characteristics (small dimples)
–Takes too many polygons to model all the dimples
![Page 24: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/24.jpg)
Modeling an Orange (2)
•Take a picture of a real orange, scan it, and “paste” onto simple geometric model–This process is texture mapping
•Still might not be sufficient because resulting surface will be smooth–Need to change local shape–Bump mapping
![Page 25: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/25.jpg)
Three Types of Mapping•Texture Mapping
–Uses images to fill inside of polygons
•Environmental (reflection mapping)–Uses a picture of the environment for texture maps
–Allows simulation of highly specular surfaces
•Bump mapping–Emulates altering normal vectors during the rendering process
![Page 26: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/26.jpg)
Texture Mapping
geometric model texture mapped
![Page 27: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/27.jpg)
Environment Mapping
![Page 28: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/28.jpg)
Bump Mapping
![Page 29: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/29.jpg)
Magnification and Minification
Texture Polygon
Magnification Minification
PolygonTexture
More than one texel can cover a pixel (minification) ormore than one pixel can cover a texel (magnification)
Can use point sampling (nearest texel) or linear filtering( 2 x 2 filter) to obtain texture values
![Page 30: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/30.jpg)
Aliasing•Point sampling of the texture can lead to aliasing errors
point samples in u,v (or x,y,z) space
point samples in texture space
miss blue stripes
![Page 31: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/31.jpg)
Area AveragingA better but slower option is to use area averaging
Note that preimage of pixel is curved
pixelpreimage
![Page 32: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/32.jpg)
![Page 33: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/33.jpg)
![Page 34: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/34.jpg)
![Page 35: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/35.jpg)
Example pointsampling
mipmapped pointsampling
mipmapped linear filtering
linear filtering
![Page 36: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/36.jpg)
Automatic Texture Coordinate Generation
• OpenGL can generate texture coordinates automatically
glTexGen{ifd}[v]()
• generation modes–GL_OBJECT_LINEAR–GL_EYE_LINEAR –GL_SPHERE_MAP (used for environmental maps)
• Check the OpenGL Red Book!–4th Ed., Chapter 8, pp.422-432, 446-450.
![Page 37: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/37.jpg)
![Page 38: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/38.jpg)
![Page 39: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/39.jpg)
![Page 40: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/40.jpg)
![Page 41: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/41.jpg)
![Page 42: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/42.jpg)
![Page 43: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/43.jpg)
Shadow Map• Similarly, by clever use of glTexGen(),
we can cast shadows on objects.
Figure 1. These diagrams were taken from Mark Kilgard’s shadow mapping presentation at GDC 2001. They illustrate the shadowing comparison that occurs in shadow mapping.
With Shadows Without Shadows
![Page 44: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/44.jpg)
More Detail
• For projective texture, see: http://developer.nvidia.com/object/Projective_Texture_Mapping.html
• For shadow map, see: http://developer.nvidia.com/object/hwshadowmap_paper.html
![Page 45: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/45.jpg)
![Page 46: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/46.jpg)
Question:
Aren’t shadow and reflection global illumination effects? Why can we do it
in the hardware pipeline?
![Page 47: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/47.jpg)
![Page 48: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/48.jpg)
![Page 49: Texture Mapping May 4, 2006. Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan](https://reader035.fdocuments.in/reader035/viewer/2022070403/56649f335503460f94c4fc56/html5/thumbnails/49.jpg)