CG Class 31, Thurs 20171130
Table of contents::
1 Spring parallel computing course
ECSE4740 Engineering Parallel Computing welcomes students wanting to learn stateoftheart parallel computing facilities that is also affordable. That is, multicore Intel Xeon and Nvidia GPU.
Qualified students from any department are welcome. You will learn things that will be useful in your work.
2 Visibility methods

Painters:
 The painter's algorithm is tricky when faces are close in Z.
 Sorting the faces is hard and maybe impossible. Then you must split some faces.
 However sometimes some objects are always in front of some other objects. Then you can render the background before the foreground.

Zbuffer:
 Subpixel objects randomly appear and disappear (aliasing).
 Artifacts occur when objects are closer than their Zextent across one pixel.
 This happens on the edge where two faces meet.

BSP tree:
 In 3D, many faces must be split to build the tree.
 The scanline algorithm can feed data straight to the video D/A. That was popular decades ago before frame buffers existed. It is popular again when frame buffers are the slowest part of the pipeline.
 A real implementation, with a moving foreground and fixed background, might combine techniques.
 References: wikipedia.
3 More comments on clipping
 Many of these algorithms were developed for HW w/o floating point, where even integer multiplication was expensive.
 Efficiency is now less important in most cases (unless you're implementing in HW).
 The idea of clipping with a 6stage pipeline is an important.

Jim Clark, a prof at
Stanford, made a 12stage pipeline using 12 copies of the same chip, and
then left Stanford to found SGI.
 Later he bankrolled Netscape and 2 other companies.
 More recently he had the world's 4th largest yacht.
4 Chapter 13 slides ctd

My note on Bresenham Line and Circle Drawing. Jack Bresenham, then at IBM invented these very fast ways to draw lines and circles with only integer addition and subtraction. My note gives stepbystep derivations by transforming slow and clear programs to fast and obscure programs.

My note on Two polygon filling algorithms.

We've seen some of this.
5 Chapter 14

Curves are the next chapter of Angel. WebGL does this worse than full OpenGL. Here is a summary. Big questions:
 What math to use?
 How should the designer design a curve?
 My notes on Bezier curves.

Partial summary:

To represent curves, use parametric (not explicit or implicit) equations.

Use connected strings or segments of lowdegree curves, not one hidegree curve.

If the adjacent segments match tangents and curvatures at their common joint, then the joint is invisible.

That requires at least cubic equations.

Higher degree equations are rarely used because they have bad properties such as:
 less local control,
 numerical instability (small changes in coefficients cause large changes in the curve),
 roundoff error.

See my note on Hi Degree Polynomials.

One 2D cartesian parametric cubic curve segment has 8 d.f.
\(x(t) = \sum_{i=0}^3 a_i t^i\),
\(y(t) = \sum_{i=0}^3 b_i t^i\), for \(0\le t\le1\).

Requiring the graphic designer to enter those coefficients would be unpopular, so other APIs are common.

Most common is the Bezier formulation, where the segment is specified by 4 control points, which also total 8 d.f.: P0, P1, P2, and P3.

The generated curve starts at P0, goes near P1 and P2, and ends at P3.

The curve stays inside the control polygon, the convex hull of the control points. A flatter control polygon means a flatter curve.

A choice not taken would be to have the generated curve also go thru P2 and P3. That's called a CatmullRomOberhauser curve. However that would force the curve to go outside the control polygon by a nonintuitive amount. That is considered undesirable.

Instead of 4 control points, a parametric cubic curve can also be specified by a starting point and tangent, and an ending point and tangent. That also has 8 d.f. It's called a Hermite curve.

The three methods (polynomial, Bezier, Hermite) are easily interconvertible.

Remember that we're using connected strings or segments of cubic curves, and if the adjacent segments match tangents and curvatures at their common joint, then the joint is invisible.

That reduces each successive segment from 8 d.f. down to 2 d.f.

This is called a Bspline.

From a sequence of control points we generate a Bspline curve that is piecewise cubic and goes near, but probably not thru, any control point (except perhaps the ends).

Moving one control point moves the adjacent few spline pieces. That is called local control. Designers like it.

One spline segment can be replaced by two spline segments that, together, exactly draw the same curve. However they, together, have more control points for the graphic designer to move individually. So now the designer can edit smaller pieces of the total spline.

Extending this from 2D to 3D curves is obvious.

Extending to homogeneous coordinates is obvious. Increasing a control point's weight attracts the nearby part of the spline. This is called a rational spline.

Making two control points coincide means that the curvature will not be continuous at the adjacent joint.
Making three control points coincide means that the tangent will not be continuous at the adjacent joint.
Making four control points coincide means that the curve will not be continuous at the adjacent joint.
Doing this is called making the curve (actually the knot sequence) Nonuniform. (The knots are the values of the parameter for the joints.)

Putting all this together gives a nonuniform rational Bspline, or a NURBS.

A Bspline surface is a grid of patches, each a bicubic parametric polynomial.

Each patch is controlled by a 4x4 grid of control points.

When adjacent patches match tangents and curvatures, the joint edge is invisible.

The surface math is an obvious extension of the curve math.
 \(x(u,v) = \sum_{i=0}^3\sum_{j=0}^3 a_{ij} u^i v^j\)
 \(y, z\) are similar.
 One patch has 48 d.f. for Cartesian points, or 64 d.f. for homogeneous points, although most of those are used to establish continuity with adjacent patches.


My extra enrichment info on Splines.

The program I showed yesterday is robotArm is Chapter 9.

To run program figure there, you first need to fix an error in figure.html. Change InitShaders to initShaders.
Many of the textbook programs have errors that prevent them from running. You can see them in the console log.

I have an Oculus Rift DK2, if anyone would like to borrow it. It's a little old but may be interesting.

Programs drawing the Utah teapot.

You do not need to learn most of those slides. Later I'll summarize what you need.