Upload
shona-martin
View
256
Download
3
Embed Size (px)
Citation preview
1
Texture Mapping
2
Texture Mapping Texture Mapping Texture Aliasing MIPmaps Environment Mapping Bump Mapping Displacement Mapping Shadow Maps Solid Textures Antialiasing
3
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
4
Modeling an Orange – 1/2 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
5
Modeling an Orange – 2/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
6
The Quest for Visual Realism
7
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
8
Texture Mapping
geometric model texture mapped
9
Decal Textures
10
Bump Mapping
11
Where does Mapping take place? Mapping techniques are implemented at the end
of the rendering pipeline Very efficient because few polygons pass
down the geometric pipeline
12
Simple Texture Mapping
s
t
x
y
z
image
geometry screen
13
Is it Simple? Although the idea is simple---map an
image to a surface---there are 3 or 4 coordinate systems involved
2D image
3D surface
14
Coordinate Systems Parametric coordinates
May be used to model curved surfaces Texture coordinates
Used to identify points in the image to be mapped World Coordinates
Conceptually, where the mapping takes place Screen Coordinates
Where the final image is really produced
15
Texture Mapping
parametric coordinates
texture coordinatesworld coordinates
screen coordinates
16
Texture Mapping = Pattern Mapping
17
Mapping Functions Basic problem is how to find the maps Consider mapping from texture coordinates to
a point a surface Appear to need three functions
x = x(s,t)
y = y(s,t)
z = z(s,t) But we really want
to go the other way
s
t
(x,y,z)
18
Backward Mapping We really want to go backwards
Given a pixel, we want to know to which point on an object it corresponds
Given a point on an object, we want to know to which point in the texture it correspondsNeed a map of the form
s = s(x,y,z)
t = t(x,y,z) Such functions are difficult to find in general
19
Sample Mapping – 1/2 In next topic, we will study parametric surf
aces Assume we want to map a point in the text
ure map T(s, t) to a point on the surface p(u, v) by a linear map of the form:u=as + bt + cv=ds + et + fas long as aebd, this mapping is invertible
20
Sample Mapping – 2/2
)(
),(
minmaxminmax
minmin
minmaxminmax
minmin
vvtt
ttvv
uuss
ssuu
21
Mapping a Texture Based on parametric texture coordinates
s
t1, 1
0, 1
0, 0 1, 0
(s, t) = (0.2, 0.8)
(0.4, 0.2)
(0.8, 0.4)
A
B C
a
bc
Texture Space Object Space
22
Two-part Mapping One solution to the mapping problem is to
first map the texture to a simple intermediate surface
Example: map to cylinder
23
Cylindrical Mapping
parametric cylinder
x = r cos 2 uy = r sin 2uz = v/h
maps rectangle in u,v space to cylinderof radius r and height h in world coordinates
s = ut = v
maps from texture space
24
Spherical MappingWe can use a parametric sphere
x = r cos 2uy = r sin 2u cos 2vz = r sin 2u sin 2v
in a similar manner to the cylinderbut have to decide where to putthe distortion
Spheres are use in environmental maps
25
Box Mapping Easy to use with simple orthographic
projection Also used in environmental maps
26
Second Mapping Map from intermediate object to actual object
Normals from intermediate to actual Normals from actual to intermediate Vectors from center of intermediate
intermediateactual
What if a ray is blocked?
27
Texture Example
The texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective mode
28
Linear Interpolation of Textures
29
Texture Mapping & Polygon Rasterization
Problems of linearly interpolatingtexture coordinates in screen space. Similar problems in the interpolations of
colors for Gouraud shading and normalsfor Phong shading.
Problems in antialiasing Expanding and shrinking
30
Example
31
Perspective Correction Dividing the texture coordinates by w Linearly interpolating (u/w, v/w, 1/w) At each pixel, dividing (interpolated)
u/w and v/w by (interpolated) 1/w
32
Aliasing Point sampling of the texture can lead to ali
asing errors
point samples in u,v (or x,y,z) space
point samples in texture space
miss blue stripes
33
Area AveragingA better but slower option is to use area averaging
Note that preimage of pixel is curved
pixelpreimage
34
Sampling Texture Maps
35
Over-Sampling indicative of aliasing high-frequency details showing up in areas
where we expect to see low frequencies
36
Spatial Filtering Prefilter the texture to remove the high fre
quencies that show up as artifacts
37
Mip Mapping MIP Mapping is one popular technique for precom
puting and performing this prefiltering Computing this series of filtered images requires o
nly a small fraction of additional storage over the original texture
38
Magnification and MinificationMore 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
Texture Polygon
Magnification Minification
PolygonTexture
39
Examples pointsampling
mipmapped pointsampling
mipmapped linear filtering
linear filtering
40
Environment Mapping
41
Sphere Mapping
42
Box Mapping
43
Bump Mapping
44
Bump Mapping
45
Bump Mapping
46
Displacement Mapping
47
Bump Mapping versus Displacement Mapping
48
Texture Mapping in Quake
49
Shadow Maps
50
Basic Steps of Shadow Maps Render the scene from the light’s point of view, Use the light’s depth buffer as a texture (shadow map), Projectively texture the shadow map onto the scene, Use “texture color” (comparison result) in fragment shading.
51
Three Dimensional or Solid Textures
52
Tri-linear Interpolation
53
Line Aliasing Ideal raster line is one pixel wide All line segments, other than vertical and h
orizontal segments, partially cover pixels Simple algorithms color
only whole pixels Lead to the “jaggies”
or aliasing Similar issue for polygons
54
Antialiasing Can try to color a pixel by adding a fraction of its
color to the frame buffer Fraction depends on percentage of pixel
covered by fragment Fraction depends on whether there is overlap
no overlap overlap
55
Area Averaging Use average area 1+2-12 as blending factor
56
Image Filtering
m
mk
n
nlljkiklij
ij
ahb
aA
,
][
H: Filter(convolution) matrix of (2m+1)×(2n+1)
010
111
010
5
1H
Examples:
121
242
121
16
1H
010
151
010
H
57
Motion Blur Jitter an object and render it multiple times, leaving
the positions of the other objects unchanged, we get dimmer copies of the jittered object
If the object is moved along a path, rather then randomly jittered, we see the trail of the object motion blur