This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **Computer Graphics
Lecture 16
Curves and Surfaces I Characters and Objects
• Important for composing the scene
• Need to design and model them in the first place Curves / curved surfaces
Can produce smooth surfaces with less parameters
• Easier to design
• Can efficiently preserve complex structures P
2 P
4 P
1 P
3 Today
• Parametric curves
–
–
–
–
– Introduction
Hermite curves
Bezier curves
Uniform cubic B-splines
Catmull-Rom spline • Bicubic patches
• Tessellation
– Adaptive tesselation
10/10/2008 Lecture 5 Types of Curves and Surfaces
• Explicit:
y = mx + b r = A rx + B ry + C r • Implicit:
Ax + By + C = 0 (x – x0)2 + (y – y0)2 – r2 = 0 • Parametric:
x = x0 + (x1 – x0)t
y = y0 + (y1 – y0)t x = x0 + rcosθ
y = y0 + rsinθ Why parametric?
• Simple and flexible
• The function of each coordinates can be defined
independently.
(x(t), y(t)) : 1D curve in 2D space
(x(t), y(t), z(t)) : 1D curve in 3D space
(x(s,t), y(s,t), z(s,t)) : 2D surface in 3D space
• Polynomial are suitable for creating smooth surfaces
with less computation
x(t) = a3t3 + a2t2 + a1t + a0 Today
• Parametric curves
–
–
–
–
– Introduction
Hermite curves
Bezier curves
Uniform cubic B-splines
Catmull-Rom spline • Bicubic patches
• Tessellation
– Adaptive tesselation
Lecture 5 Hermite curves
• A cubic polynomial
x(t) = a3t3 + a2t2 + a1t + a0
• t ranging from 0 to 1
• Polynomial can be specified by the position
of, and gradient at, each endpoint of curve. 10/10/2008 Lecture 5 Family of Hermite curves.
y(t)
Note :
Start points on
left. x(t)
10/10/ 10/10/2008 Lecture 5 Finding Hermite coefficients
Can solve them by using the boundary conditions
X(t) = a3t3 + a2t2 + a1t + a0, X’(t) = 3a3t2 + 2a2t + a1
Substituting for t at each endpoint: Equation and
derivative
Want to
compute ai x0 = X(0) = a0 x0’ = X’(0) = a1 x1 = X(1) = a3 + a2 + a1 + a0 x1’= X’(1) = 3a3 + 2a2+ a1 And the solution is:
a0 = x0 a1 = x0’ a2 = -3x0 – 2x0’ + 3x1 – x1’ a3 = 2x0 + x0’- 2x1 + x1’ X(t) = (2x0 + x0’- 2x1 + x1’ ) t3 + Lecture05 – 2x0’ + 3x1 – x1’ ) t2 + (x0’ ) t +
(-3x
10/10/2008 Finding Hermite coefficients
Can solve them by using the boundary conditions
X(t) = a3t3 + a2t2 + a1t + a0, X’(t) = 3a3t2 + 2a2t + a1
Substituting for t at each endpoint:
x0 = X(0) = a0 x0’ = X’(0) = a1 x1 = X(1) = a3 + a2 + a1 + a0 x1’= X’(1) = 3a3 + 2a2+ a1 boundary
conditions And the solution is:
a0 = x0 a1 = x0’ a2 = -3x0 – 2x0’ + 3x1 – x1’ a3 = 2x0 + x0’- 2x1 + x1’ X(t) = (2x0 + x0’- 2x1 + x1’ ) t3 + Lecture05 – 2x0’ + 3x1 – x1’ ) t2 + (x0’ ) t +
(-3x
10/10/2008 Finding Hermite coefficients
Can solve them by using the boundary conditions
X(t) = a3t3 + a2t2 + a1t + a0, X’(t) = 3a3t2 + 2a2t + a1
Substituting for t at each endpoint:
x0 = X(0) = a0 x0’ = X’(0) = a1 x1 = X(1) = a3 + a2 + a1 + a0 x1’= X’(1) = 3a3 + 2a2+ a1 And the solution is: solving for coefficients a0 = x0 a1 = x0’ a2 = -3x0 – 2x0’ + 3x1 – x1’ a3 = 2x0 + x0’- 2x1 + x1’ X(t) = (2x0 + x0’- 2x1 + x1’ ) t3 + Lecture05 – 2x0’ + 3x1 – x1’ ) t2 + (x0’ ) t +
(-3x
10/10/2008 The Hermite matrix: MH
The resultant polynomial can be expressed in matrix form:
X(t) = tTMHq ( q is the control vector) We can now define a parametric polynomial for each
coordinate required independently, ie. X(t), Y(t) and Z(t) 10/10/2008 Lecture 5 Hermite Basis (Blending) Functions Hermite Basis (Blending) Functions The graph shows the shape of the
four basis functions – often called
blending functions. x0 x1 They are labelled with the elements
of the control vector that they
weight. x0/ Note that at each end only position
is non-zero, so the curve must
touch the endpoints
10/10/2008 Lecture 5 x1/ Bézier Curves
• Hermite cubic curves are difficult to model –
need to specify point and gradient. • Paul de Casteljau who was working for Citroën,
invented another way to compute the curves
• Publicised by Pierre Bézier from Renault
• By only giving points instead of the derivatives Bézier Curves (2)
P Can define a curve by specifying 2 endpoints and 2
additional control points 2 The two middle points are used to specify the gradient at
the endpoints
Fit within the convex hull by the control points P 4 P P 3 1 P
3 P P
P 2
1 10/10/2008 Lecture 5 4 Bézier Matrix
• The cubic form is the most popular
X(t) = tTMBq (MB is the Bézier matrix)
• With n=4 and r=0,1,2,3 we get: • Similarly for Y(t) and Z(t) 10/10/2008 Bézier blending functions
This is how the
polynomials for each
coefficient looks like
The functions sum to 1 at
any point along the curve.
Endpoints have full weight
The weights of each
function is clear and the
labels show the control
points being weighted.
10/10/2008 q0 q3
q1 q2 How to produce complex, long curves?
• We could only use 4 control points to design
curves.
• What if we want to produce long curves with
complex shapes.
• How do can we do that? .
10/10/2008 Lecture 5 Drawing Complex Long Curves
● Using higher order curves
○ costly
○ Need many multiplications
● Pierce together low order curves
○ Need to make sure the connection points are smooth 10/10/2008 Lecture 5 Continuity between curve segments
n
• If the direction and magnitude of d / dt [X(t)] are equal
at the join point, the curve is called Cn continuous
• i.e. if two curve segments are simply connected, the
curve is C0 continuous
• If the tangent vectors of two cubic curve segments are
equal at the join point, the curve is C1 continuous Continuity between curve segments
• If the directions (but not necessarily the magnitudes) of
two segments’ tangent vectors are equal at the join
1
point, the curve has G continuity Continuity with Hermite and Bezier
Curves
– How to achieve C0,C1,G1 continuity? Joining Bezier Curves
• G1 continuity is provided at the endpoint when
P3 – P4 = k (P4 – P5)
• if k=1, C 1continuity is obtained Uniform Cubic B-Splines
• Another popular form of curves
• The curve does not necessarily pass through the
control points
• Can produce a longer continuous curve without
worrying about the boundaries
• Has C2 continuity at the boundaries Lecture 5 Uniform Cubic B-Splines (2)
• The matrix form and the basis functions
• The knots specify the range of the curve 10/10/2008 Lecture 5 Uniform Cubic B-Splines (3)
• This is how the basis look like over the domain
• The initial part is defined after passing the fourth
knot 0
10/10/2008 t
3 Lecture 5 m+1 Another usage of uniform cubic
B-splines
• Representing the joint angle trajectories of
characters and robots
• Need more control points to represent a
longer continuous movement
• Need C2 continuity to make the acceleration
smooth
• And not changing the torques suddenly Catmull-Rom Spline
• A curve that interpolates control points
• The tangent vectors at the endpoints of a
Hermite curve is set such that they are
decided by the two surrounding control
points Catmull-Rom Spline
• C1 continuity Today
• Parametric curves
–
–
–
–
– Introduction
Hermite curves
Bezier curves
Uniform cubic B-splines
Catmull-Rom spline • Bicubic patches
• Tessellation
– Adaptive tessellation
10/10/2008 Lecture 5 Bicubic patches
• The concept of parametric curves can be
extended to surfaces
• The cubic parametric curve is in the form of Q(t)
=tTM q where q=(q1,q2,q3,q4) : qi control points,
M is the basis matrix (Hermite or Bezier,…), tT=
(t3, t2, t, 1) • Now we assume qi to vary along a parameter s,
• Qi(s,t)=tTM [q1(s),q2(s),q3(s),q4(s)]
• qi(s) are themselves cubic curves, we can write
them in the form … Bicubic patches
where q is a 4x4 matrix
Each column contains the control points of
q1(s),…,q4(s)
x,y,z computed by Bézier example
• We compute (x,y,z) by .
14/10/2008
Lecture 6
edu/dlittle/java/parametricequations/beziersurfaces/index.html Today
• Parametric curves
–
–
–
–
– Introduction
Hermite curves
Bezier curves
Uniform cubic B-splines
Catmull-Rom spline • Bicubic patches
• Tessellation
– Adaptive tessellation
10/10/2008 Lecture 5 Displaying Bicubic patches.
• Directly rasterizing bicubic patches is not so easy
• Need to convert the bicubic patches into a
polygon mesh
– tessellation • Need to compute the normals
– vector cross product of the 2 tangent vectors. Normal Vectors Tangent vectors can be computed by computing the partial
derivatives
Then computing the cross product of the two partial
derivative vectors Tessellation
• As computers are optimized for rendering
triangles, the easiest way to display parametric
surfaces is to convert them into triangle meshes
• The simplest way is to do uniform tessellation,
which samples points uniformly in the parameter
space 14/10/2008 Lecture 6 Uniform Tessellation
•
•
•
• Sampling points uniformly with the parameters
What are the problems with uniform tessellation?
Which area needs more tessellation?
Which area does not need much tessellation? Adaptive Tessellation
• Adaptive tessellation – adapt the size of triangles to
the shape of the surface Adaptive Tessellation
• For every triangle edges, check if each edge is
tessellated enough (curveTessEnough())
• If all edges are tessellated enough, check if the
whole triangle is tessellated enough as a whole
(triTessEnough())
• If one or more of the edges or the triangle’s
interior is not tessellated enough, then further
tessellation is needed Adaptive Tessellation
• When an edge is not tessellated enough, a
point is created halfway between the edge
points’ uv-values
• New triangles are created and the tessellator
is once again called with the new triangles as
input Four cases of further tessellation Adaptive Tessellation
AdaptiveTessellate(p,q,r)
•
•
•
• tessPQ=not curveTessEnough(p,q)
tessQR=not curveTessEnough(q,r)
tessRP=not curveTessEnough(r,p)
If (tessPQ and tessQR and tessRP)
–
–
–
– • AdaptiveTessellate(p,(p+q)/2,(p+r)/2);
AdaptiveTessellate(q,(q+r)/2,(q+p)/2);
AdaptiveTessellate(r,(r+p)/2,(r+q)/2);
AdaptiveTessellate((p+q)/2,(q+r)/2,(r+p)/2); else if (tessPQ and tessQR)
– AdaptiveTessellate(p,(p+q)/2,r);
– AdaptiveTessellate((p+q)/2,(q+r)/2,r);
– AdaptiveTessellate((p+q)/2,q,(q+r)/2); • else if (tessPQ)
– AdaptiveTessellate(p,(p+q)/2,r);
– AdaptiveTessellate(q,r,(p+q)/2); • Else if (not triTessEnough(p,q,r))
AdaptiveTessellate((p+q+r)/3,p,q);
AdaptiveTessellate((p+q+r)/3,q,r);
AdaptiveTessellate((p+q+r)/3,r,p);
end; curveTessEnough
• Say you are to judge whether ab needs
tessellation
• You can compute the midpoint c, and compute
the curve’s distance l from d, the midpoint of ab
• Check if l/||a-b|| is under a threshold
• Can do something similar for triTessEnough
– Sample at the mass center and calculate its distance
from the triangle
c
a d b On-the-fly tessellation
• In many cases, it is preferred to tessellate
on-the-fly
• The size of the data can be kept small
• Tessellation is a highly parallel process
– Can make use of the GPU • The shape may deform in real-time On-the-fly tessellation
• So, say in a dynamic environment, what are
the factors that we need to take into account
when doing the tessellation?
– in addition to curvature? Other factors? Other factors? Other factors? Other factors to evaluate
•
•
•
•
• Inside the view frustum
Front facing
Occupying a large area in screen space
Close to the silhouette of the object
Illuminated by a significant amount of
specular lighting Summary
•
•
• Hermite, Bezier, B-Spline curves
Bicubic patches
Tessellation
•
• Triangulation of parametric surfaces
On-the-fly tessellation Reading for this lecture
• Foley et al. Chapter 11, section 11.2 up to and including
11.2.3
• Introductory text Chapter 9, section 9.2 up to and
including section 9.2.4
• Foley at al., Chapter 11, sections 11.2.3, 11.2.4, 11.2.9,
11.2.10, 11.3 and 11.5.
• Introductory text, Chapter 9, sections 9.2.4, 9.2.5, 9.2.7,
9.2.8 and 9.3.
• Real-time Rendering 2nd Edition Chapter 12.1-3
10/10/2008 Lecture 5 ...

View
Full Document

- Spring '14
- Bezier Curves, Cubic Hermite spline, uniform cubic b-splines