cs559: computer graphics lecture 20: project 2 review and texture mapping li zhang spring 2010 many...
TRANSCRIPT
![Page 1: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/1.jpg)
CS559: Computer Graphics
Lecture 20: Project 2 Review and Texture mappingLi Zhang
Spring 2010
Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee Wolfe, DePaul tutorial teaching texture mapping visually
![Page 2: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/2.jpg)
Sample Code by Chi Man Liu
![Page 3: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/3.jpg)
Other basic features• How to change speed?
– Add a slider with a callback to change timePerFrame
• How to orient a car? • How to draw trees?
– A triangle + a rectangle– A cone + a cylinder
• Using gluQuadrics
![Page 4: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/4.jpg)
Piecewise Cubics
P1
P4
P3
P2
![Page 5: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/5.jpg)
Piecewise CubicsTask1: draw the whole curveDrawCubic(P4,P1,P2,P3);DrawCubic(P1,P2,P3,P4);DrawCubic(P2,P3,P4,P1);DrawCubic(P3,P4,P1,P2);
DrawCubic(Q1,Q2,Q3,Q4)For (t=0; t < 0.1; t+=0.01){ A=computePoint(Q1,Q2,Q3,Q4,t); B=computePoint(Q1,Q2,Q3,Q4,t+0.01);drawLine(A,B);}
Task1: draw the whole curveDrawCubic(P4,P1,P2,P3);DrawCubic(P1,P2,P3,P4);DrawCubic(P2,P3,P4,P1);DrawCubic(P3,P4,P1,P2);
DrawCubic(Q1,Q2,Q3,Q4)For (t=0; t < 0.1; t+=0.01){ A=computePoint(Q1,Q2,Q3,Q4,t); B=computePoint(Q1,Q2,Q3,Q4,t+0.01);drawLine(A,B);}
Task 2: find where the train is at time t:If (0<=t<1) return computePoint(P4,P1,P2,P3,t)If (1<=t<2) return computePoint(P1,P2,P3,P4,t-1);If (2<=t<3) return computePoint(P2,P3,P4,P1,t-2);If (3<=t<4) return computePoint(P3,P4,P1,P2,t-3);
Task 2: find where the train is at time t:If (0<=t<1) return computePoint(P4,P1,P2,P3,t)If (1<=t<2) return computePoint(P1,P2,P3,P4,t-1);If (2<=t<3) return computePoint(P2,P3,P4,P1,t-2);If (3<=t<4) return computePoint(P3,P4,P1,P2,t-3);
Fine with Hermite, Catmull-Ron, CardinalHow about Bezier?
![Page 6: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/6.jpg)
Arc-Length Parameterization• Arbitrary curves?
P1
P4
P3
P2
dudu
uds
t
0
)(f
![Page 7: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/7.jpg)
Arc-length parameterization
Freeformx
y
0 1t
)(
)()(
2
1
tf
tft
y
xf
0 Ls
)(
)()(
2
1
sg
sgs
y
xg
Arc-length parameterization
dtdt
tdfs
t
0
)(
![Page 8: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/8.jpg)
Correct Orientation in 3D• Define and interpolate up vector
![Page 9: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/9.jpg)
Implement simple physics• Energy conservation
![Page 10: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/10.jpg)
Multiple Cars• Each has its own parameter t, assuming arc-
length parameterization
![Page 11: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/11.jpg)
Hack Shadow
(XL,YL,ZL)
(x,y,z)
![Page 12: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/12.jpg)
Train smoke?• Balls moving upward and dissipating
![Page 13: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/13.jpg)
Texture Mapping
• Important topic: nearly all objects textured– Wood grain, faces, bricks and so on– Adds visual detail to scenes
Polygonal model With surface texture
![Page 14: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/14.jpg)
Adding Visual Detail
• Basic idea: use images instead of more polygons to represent fine scale color variation
![Page 15: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/15.jpg)
Parameterization
geometrygeometry
++ ==
imageimage texture maptexture map
• Q: How do we decide where on the geometryeach color from the image should go?
![Page 16: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/16.jpg)
Option: Varieties of mappings
[Paul Bourke][Paul Bourke]
![Page 17: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/17.jpg)
Option: unfold the surface
[Piponi2000]
![Page 18: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/18.jpg)
Option: make an atlas
[Sander2001]
charts atlas surface
![Page 19: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/19.jpg)
Outline• Types of mappings• Interpolating texture coordinates • Broader use of textures
![Page 20: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/20.jpg)
How to map object to texture?• To each vertex (x,y,z in object coordinates), must
associate 2D texture coordinates (s,t)• So texture fits “nicely” over object
![Page 21: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/21.jpg)
Implementing texture mapping• A texture lives in it own abstract image coordinates
paramaterized by (u,v) in the range ([0..1], [0..1]):
• It can be wrapped around many different surfaces:
• Note: if the surface moves/deforms, the texture goes with it.
![Page 22: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/22.jpg)
How to map object to texture?• To each vertex (x,y,z in object coordinates), must
associate 2D texture coordinates (s,t)• So texture fits “nicely” over object
![Page 23: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/23.jpg)
Planar mapping• Like projections, drop z coord (u,v) = (x/W,y/H)• Problems: what happens near silhouettes?
![Page 24: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/24.jpg)
Cylindrical Mapping• Cylinder: r, θ, z with (u,v) = (θ/(2π),z)
– Note seams when wrapping around (θ = 0 or 2π)
![Page 25: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/25.jpg)
Basic procedure• First, map (square) texture to basic map shape• Then, map basic map shape to object
– Or vice versa: Object to map shape, map shape to square
• Usually, this is straightforward– Maps from square to cylinder, plane, …– Maps from object to these are simply coordinate
transform
![Page 26: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/26.jpg)
Spherical Mapping• Convert to spherical coordinates: use
latitude/long.– Singularities at north and south poles
![Page 27: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/27.jpg)
Cube Mapping
![Page 28: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/28.jpg)
Cube Mapping
![Page 29: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/29.jpg)
Piecewise Mapping
From Steve Marschner
![Page 30: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/30.jpg)
Slides from Leonard Mcmillan
![Page 31: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/31.jpg)
Outline• Types of projections• Interpolating texture coordinates • Broader use of textures
![Page 32: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/32.jpg)
1st idea: Gouraud interp. of texcoords
1I
2I
3I
sI
Using barycentric Coordinates
![Page 33: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/33.jpg)
1st idea: Gouraud interp. of texcoords
Scan line
1I
2I
3I
1y
2y
3y
syaI bI
1 2 2 1
1 2
( ) ( )s sa
I y y I y yI
y y
31
1331 )()(
yy
yyIyyII ssb
ab
asbsbas xx
xxIxxII
)()(
sI
![Page 34: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/34.jpg)
Artifacts• McMillan’s demo of this is at
http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide05.html
• Another example http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html
• What artifacts do you see?• Why?• Hint: problem is in interpolating parameters
![Page 35: CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,](https://reader035.vdocuments.mx/reader035/viewer/2022081516/5697bfd91a28abf838caf85f/html5/thumbnails/35.jpg)
Interpolating Parameters• The problem turns out to be fundamental to
interpolating parameters in screen-space– Uniform steps in screen space uniform steps in world space
Texture image