+ All Categories
Home > Documents > Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0);...

Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0);...

Date post: 18-Dec-2015
Category:
Upload: stanley-hicks
View: 216 times
Download: 0 times
Share this document with a friend
Popular Tags:
47
Transcript
Page 1: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 2: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 3: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 4: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 5: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 6: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 7: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 8: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

Q about GL to render polygon

(A)glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(1,1,0);glEnd();

(B)glBegin(GL_QUADS) glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(1,0,0); glVertex3f(1,1,0);glEnd();

(C)glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(0,1,0);glEnd();

(D)glBegin(GL_QUADS) glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(1,1,0); glVertex3f(1,0,0);glEnd();

(E) I just really don’t know

Page 9: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 10: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

• Turn on all pixels inside the triangle

• But what about pixels on the edge?

Page 11: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 12: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

[Rasterization Rules (Direct3D 10) – MSDN]

Top-Left Rasterization Rule

Page 13: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 14: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

Q about Normals

What is the per-polygon normal shown?

(A) 1,1,1(B) 0,0,1(C)1,0,0(D)0,1,0(E) Don’t know

Page 15: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

Q about Normals

What is the per-vertex normal at point A?

(A) 1,1,1(B) 1,1,-1(C)1/sqrt(3), 1/sqrt(3), 1/sqrt(3)(D)- 1/sqrt(3), 1/sqrt(3),1/sqrt(3)(E) Don’t know

Page 16: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 17: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 18: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Limitations of Polygonal Meshes

• Planar facets (& silhouettes)

• Fixed resolution

• Deformation is difficult

• No natural parameterization (for texture mapping)

Page 19: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Can We Disguise the Facets?

Page 20: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Some Non-Polygonal Modeling Tools

Extrusion

Spline Surfaces/Patches

Surface of Revolution

Quadrics and other implicit polynomials

Page 21: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Continuity definitions:• C0 continuous

– curve/surface has no breaks/gaps/holes

• G1 continuous– tangent at joint has same direction

• C1 continuous– curve/surface derivative is continuous

– tangent at join has same direction and magnitude

• Cn continuous– curve/surface through nth derivative

is continuous

– important for shading

Page 22: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

BSpline (approximation)

Definition: What's a Spline?

• Smooth curve defined by some control points

• Moving the control points changes the curve

Interpolation Bézier (approximation)

Page 23: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Interpolation Curves / Splines

www.abm.org

Page 24: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Linear Interpolation

• Simplest "curve" between two points

Q(t) = Spline Basis Functions

a.k.a. Blending Functions

Page 25: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);
Page 26: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

• [bilinear interpolation]

Page 27: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Q about bi-linear interpolation

What is the value at point A?

(A) 1(B) 2(C)3(D)4(E) Don’t know

Page 28: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Suppose you start with the smallest image and need a big one?

Interpolation is not just about surfaces, used heavily in images

Page 29: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Nearest, bilinear, b-spline interpolation

Page 30: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Interpolation vs. Approximation Curves

Interpolation

curve must pass through control points

Approximation

curve is influenced by control points

Page 31: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Interpolation vs. Approximation Curves

• Interpolation Curve – over constrained → lots of (undesirable?) oscillations

• Approximation Curve – more reasonable?

Page 32: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic Bézier Curve• 4 control points

• Curve passes through first & last control point

• Curve is tangent at P0 to (P0-P1) and at P4 to (P4-P3)

A Bézier curve is bounded by the convex hull of its control points.

Page 33: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Linear Interpolation

• Simplest "curve" between two points

Q(t) = Spline Basis Functions

a.k.a. Blending Functions

Page 34: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic Bézier Curve

Bernstein Polynomials

Page 35: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic BSplines

• ≥ 4 control points• Locally cubic• Curve is not constrained to pass through any

control points

A BSpline curve is also bounded by the convex hull of its control points.

Page 36: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic BSplines

Page 37: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic BSplines

• Can be chained together• Better control locally (windowing)

Page 38: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Bézier is not the same as BSpline

Bézier BSpline

Page 39: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Bézier is not the same as BSpline

• Relationship to the control points is different

Bézier

BSpline

Page 40: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

NURBS (generalized BSplines)

• BSpline: uniform cubic BSpline

• NURBS: Non-Uniform Rational BSpline– non-uniform = different spacing between the

blending functions, a.k.a. knots– rational = ratio of polynomials (instead of cubic)

Page 41: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Bicubic Bezier Patch

Page 42: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Editing Bicubic Bezier Patches

Curve Basis Functions

Surface Basis Functions

Page 43: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Modeling with Bicubic Bezier Patches

• Original Teapot specified with Bezier Patches

Page 44: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Cubic Bézier Curve

• de Casteljau's algorithm for constructing Bézier curves

t

t

ttt

t

http://www.youtube.com/watch?v=oDzD9bqYsgA&NR=1

Page 45: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Doo-Sabin Subdivision

Page 46: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Doo-Sabin Subdivision

http://www.ke.ics.saitama-u.ac.jp/xuz/pic/doo-sabin.gif

Page 47: Q about GL to render polygon (A) glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,1,0);

MIT EECS 6.837, Durand and Cutler

Henrik Wann Jensen

• Bezier Patches?

or

• Triangle Mesh?


Recommended