Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment...
Transcript of Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment...
![Page 1: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/1.jpg)
Texture Mapping
COMP 575/770
Spring 2013
![Page 2: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/2.jpg)
Textures
Goal: Add visual detail to 3D objects
![Page 3: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/3.jpg)
Textures
Option 1: Model everything with lots of little triangles
Way too much work (for computers and for people)
Option 2: Paint an image on the model
The image is called a texture
![Page 4: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/4.jpg)
Texture Mapping Overview
(x,y,z) (s,t)
0 1
1
(u,v)
0 1
1
(u,v)
Map each point on the surface to a point in the texture image
![Page 5: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/5.jpg)
Outline
Introduction
Surface Parameterization
Texture Mapping
Texture Filtering
Variations
![Page 6: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/6.jpg)
Surface Parameterization
How to assign (u,v) coordinates to a surface?
Trivial for rectangles
Easy for spheres too (just use longitude, latitude)
[ma
p: P
ete
r H. D
an
a]
![Page 7: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/7.jpg)
Surface Parameterization
Easy for other parametric surfaces
Surfaces defined by functions of two variables
[Wo
lfe
/ S
G9
7 S
lide
se
t]
![Page 8: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/8.jpg)
Surface Parameterization
Not so easy for bunnies
Or other arbitrary triangle meshes
Typically performed by 3D modeling software
![Page 9: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/9.jpg)
Surface Parameterization
Option 1: Project to parametric surfaces
[CS
46
7 s
lide
s]
![Page 10: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/10.jpg)
Surface Parameterization
Option 2: Unwrap the model
[Piponi 2000]
![Page 11: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/11.jpg)
Surface Parameterization
Option 3: Make an atlas
charts atlas surface
[Sander 2001]
![Page 12: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/12.jpg)
Outline
Introduction
Surface Parameterization
Texture Mapping
Texture Filtering
Variations
![Page 13: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/13.jpg)
Texture Mapping
After parameterization, we get (u,v) coordinates for each vertex
Use interpolation for (u,v) values in the interior of triangles
Essentially, (u,v) texture coordinates are another vertex attribute
![Page 14: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/14.jpg)
Texture Mapping
Let’s use this method to apply a checkerboard pattern to a square, viewed at an angle
This is what we want:
![Page 15: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/15.jpg)
Texture Mapping
This is what we get:
![Page 16: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/16.jpg)
Perspective-Correct Mapping
Fundamental problem with interpolation in screen-space
Uniform screen-space steps ≠ uniform world-space steps
![Page 17: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/17.jpg)
Perspective-Correct Mapping
Perspective foreshortening doesn’t get applied to texture coordinates with linear interpolation
Instead of interpolating (u,v), interpolate (u/z,v/z)
Or, since w ∝ 1/z, interpolate (uw, vw)
Perform divisions: u = uw/w, v = vw/w for each fragment
This gives perspective-correct texture mapping
![Page 18: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/18.jpg)
Outline
Introduction
Surface Parameterization
Texture Mapping
Texture Filtering
Variations
![Page 19: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/19.jpg)
Texture Filtering
Texture image is, after all, a set of discrete samples (called texels)
(u,v) coordinates at a surface point rarely land exactly on a sample
Need to use reconstruction filters to figure out the texture values between samples
![Page 20: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/20.jpg)
Texture Filtering
Nearest-neighbor filtering
![Page 21: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/21.jpg)
Texture Filtering
Bilinear filtering
![Page 22: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/22.jpg)
Texture Filtering
What if the area “covered” by a pixel contains multiple texels?
Need a way to combine multiple texels to a single value
Can pre-filter images using
MIP mapping
Summed area tables
![Page 23: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/23.jpg)
MIP Mapping
MIP = multim im parvo (“many things in one place”)
Keep a bunch of downsampled images at different sizes (called levels)
![Page 24: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/24.jpg)
MIP Mapping
Choose the level based on depth
Alternately, interpolate between two levels (trilinear filtering)
Without MIP mapping With MIP mapping
![Page 25: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/25.jpg)
Summed Area Tables
For each texel, store the sum of texel values below it and to its right
Sum of values within any rectangle = difference of two texel values
![Page 26: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/26.jpg)
Summed Area Tables
Can compute more accurate averages
MIP mapping is simpler, and supported in GPUs
MIP mapping Summed Area Tables
![Page 27: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/27.jpg)
Outline
Introduction
Surface Parameterization
Texture Mapping
Texture Filtering
Variations
![Page 28: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/28.jpg)
Texture Mapping Variations
So far, we’ve used textures to specify 𝑘𝑎 , 𝑘𝑑 , 𝑘𝑠
But there are many more uses! For example, can store 𝑘𝑠, 𝑝 in a separate specular map
![Page 29: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/29.jpg)
Bump Mapping
Intensity = offset from surface
Used to derive varying surface normals
![Page 30: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/30.jpg)
Normal Mapping
Explicitly specify surface normals
[Paolo Cignoni]
![Page 31: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/31.jpg)
Displacement Mapping
Like bump mapping, but geometry shader used to actually displace the surface
![Page 32: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/32.jpg)
Light Mapping
Texture stores intensity/color of light incident at the surface
Precomputed using global illumination techniques
Without light map With light map
![Page 33: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around](https://reader036.fdocuments.us/reader036/viewer/2022062505/5e0b84d95271ef36c145e19f/html5/thumbnails/33.jpg)
Environment Mapping
Texture is an image of a complicated environment, sampled in all directions around a point
Images from Illumination and Reflection Maps: Simulated Objects in Simulated and Real Environments Gene Miller and C. Robert Hoffman SIGGRAPH 1984 “Advanced Computer Graphics Animation” Course Notes