![Page 1: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/1.jpg)
CS559: Computer Graphics
Lecture 21: Subdivision, Bspline, and Texture mappingLi Zhang
Spring 2008
![Page 2: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/2.jpg)
Today• Finish on curve modeling• Start Texture mapping
• Reading– Shirley: Ch 15.6.2– Redbook: Ch 9– (optional) Moller and Haines: Real‐Time Rendering, 3e, Ch 6
• Linux: /p/course/cs559‐lizhang/public/readings/6_texture.pdf
• Windows: P:\course\cs559‐lizhang\public\readings\6_texture.pdf
![Page 3: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/3.jpg)
Changing u
De Casteljau algorithm, Recursive Rendering
u=0.5 u=0.25, u=0.5, u=0.75
![Page 4: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/4.jpg)
Subdivision
DeCasteljau(float p[N][3], float u) {
for (int n = N‐1; n >= 1; ‐‐n) {for (int j = 0; j < n; ++j) {
p[j][0] = (1‐u) * p[j][0] + u * p[j+1][0];p[j][1] = (1‐u) * p[j][1] + u * p[j+1][1];p[j][2] = (1‐u) * p[j][2] + u * p[j+1][2];
}}//(p[0][0], p[0][1], p[0][2]) saves the result
}
DeCasteljau(float p[N][3], float u) {
for (int n = N‐1; n >= 1; ‐‐n) {for (int j = 0; j < n; ++j) {
p[j][0] += u*(p[j+1][0]‐p[j][0]);p[j][1] += u*(p[j+1][1]‐p[j][1]);p[j][2] += u*(p[j+1][2]‐p[j][2]);
}}//(p[0][0], p[0][1], p[0][2]) saves the result
}
![Page 5: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/5.jpg)
Subdivision• Given a Bezier curve defined by P0, P1, P2, ..., Pn• we want to find two sets of n+1 control points Q0, Q1, Q2, ..., Qn and R0, R1, R2, ..., Rn such that – the Bézier curve defined by Qi's is the piece of the original Bézier curve on [0,u]
– the Bézier curve defined by Ri's is the piece of the original Bézier curve on [u,1]
![Page 6: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/6.jpg)
Bezier Curve Subdivision
p1
p0p3
p2
http://www1.cs.columbia.edu/~cs4160/html06f/
u=0.5
![Page 7: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/7.jpg)
Bezier Curve Subdivision
p1
p0p3
p2
http://www1.cs.columbia.edu/~cs4160/html06f/
u=0.5
![Page 8: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/8.jpg)
A 6th degree subdivision example
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier‐sub.html
![Page 9: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/9.jpg)
Bezier Curve Subdivision• Why is subdivision useful?
– Collision/intersection detection• Recursive search
– Good for curve editing and approximation
![Page 10: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/10.jpg)
Open Curve Approxmiation
![Page 11: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/11.jpg)
Closed Curve Approximation
![Page 12: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/12.jpg)
Interpolate control points
Has local control C2 continuity
Natural cubics Yes No Yes
Hermite cubics Yes Yes No
Cardinal Cubics Yes Yes No
Bezier Cubics Yes Yes No
![Page 13: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/13.jpg)
Interpolate control points
Has local control C2 continuity
Natural cubics Yes No Yes
Hermite cubics Yes Yes No
Cardinal Cubics Yes Yes No
Bezier Cubics Yes Yes No
Bspline Curves No Yes Yes
![Page 14: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/14.jpg)
Bsplines
• Given p1,…pn, define a curve that approximates the curve.
∑=
=n
iii tbt
1)()( pf
If bi(t) is very smooth, so will be f
If bi(t) has local support, f will have local control
![Page 15: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/15.jpg)
Uniform Linear B‐splines
b1,2(t)
0 1 2 3 40
1
∑=
=n
iii tbt
1)()( pf
b1(t) b2(t) b3(t)
p1
p2
pn
)()( 2,02, itbtbi −=
⎪⎩
⎪⎨
⎧∈−∈
=otherwise0
)2,1[2)1,0[
)(2,0 uuuu
ub
![Page 16: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/16.jpg)
How can we make the curve smooth?
• Convolution/filtering
∑=
=n
iii tbt
1)()( pf
)(Box)()(Box)(1
ttbttn
iii ⊗⎟⎠
⎞⎜⎝
⎛=⊗ ∑
=
pf
( ) ⎟⎠
⎞⎜⎝
⎛⊗= ∑
=
n
iii ttb
1)(Box)( p
1
1
0
Box(t)
t
⊗
![Page 17: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/17.jpg)
Uniform Quadratic B‐splines
0
1
0 1 2 3 4 5
∑=
=n
iii tbt
1)()( pf
![Page 18: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/18.jpg)
Uniform Cubic Bspline
b0(t)
b1(t-1)
b3(t-3)
b2(t-2)
23
t=i t=i+1 t=i+2 t=i+3 t=i+4
∑=
=n
iii tbt
1)()( pf
![Page 19: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/19.jpg)
Uniform B‐splines• Why smoother?
– Linear = box filter ⊗ box filter– Quadric = linear ⊗ box filter– Cubic = quadric ⊗ box filter
• Sum = 1 property, translation invariant
• Local control
• C(k‐2) continuity
0
1
0 1 2 3 4 5 6 7 8 9 10
∑=
=n
iii tbt
1)()( pf
![Page 20: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/20.jpg)
Interpolate control points
Has local control C2 continuity
Natural cubics Yes No Yes
Hermite cubics Yes Yes No
Cardinal Cubics Yes Yes No
Bezier Cubics Yes Yes No
Bspline Curves No Yes Yes
![Page 21: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/21.jpg)
Texture Mapping
Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee Wolfe, DePaul tutorial teaching texture mapping visually
![Page 22: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/22.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 23: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/23.jpg)
Adding Visual Detail
• Basic idea: use images instead of more polygons to represent fine scale color variation
![Page 24: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/24.jpg)
Parameterization
geometry
+ =
image texture map
• Q: How do we decide where on the geometryeach color from the image should go?
![Page 25: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/25.jpg)
Option: Varieties of mappings
[Paul Bourke]
![Page 26: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/26.jpg)
Option: unfold the surface
[Piponi2000]
![Page 27: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/27.jpg)
Option: make an atlas
[Sander2001]
charts atlas surface
![Page 28: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/28.jpg)
Outline
• Types of mappings
• Interpolating texture coordinates
• Broader use of textures
![Page 29: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/29.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 30: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/30.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 31: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/31.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 32: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/32.jpg)
Planar mapping
• Like projections, drop z coord (u,v) = (x/W,y/H)
• Problems: what happens near silhouettes?
![Page 33: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/33.jpg)
Cylindrical Mapping
• Cylinder: r, θ, z with (u,v) = (θ/(2π),z)– Note seams when wrapping around (θ = 0 or 2π)
![Page 34: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/34.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 35: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/35.jpg)
Spherical Mapping
• Convert to spherical coordinates: use latitude/long.– Singularities at north and south poles
![Page 36: CS559: Computer Graphicspages.cs.wisc.edu/~lizhang/courses/cs559-2008s/syllabus/03-12-cur… · • Given a Bezier curve defined by P 0, P 1, P 2, ..., P n • we want to find two](https://reader034.vdocuments.us/reader034/viewer/2022050222/5f72faa15824c37aaa3df1fb/html5/thumbnails/36.jpg)
Cube Mapping