CG Lecture 29, Thu 2016-11-17

  1. Visibility methods:

    1. Painters:
      1. The painter's algorithm is tricky when faces are close in Z.
      2. Sorting the faces is hard and maybe impossible. Then you must split some faces.
      3. However sometimes some objects are always in front of some other objects. Then you can render the background before the foreground.
    2. Z-buffer:
      1. Subpixel objects randomly appear and disappear (aliasing).
      2. Artifacts occur when objects are closer than their Z-extent across one pixel.
      3. This happens on the edge where two faces meet.
    3. BSP tree:
      1. In 3D, many faces must be split to build the tree.
    4. 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.
    5. A real implementation, with a moving foreground and fixed background, might combine techniques.
    6. References: wikipedia.
  2. More comments on clipping:

    1. Many of these algorithms were developed for HW w/o floating point, where even integer multiplication was expensive.
    2. Efficiency is now less important in most cases (unless you're implementing in HW).
    3. The idea of clipping with a 6-stage pipeline is an important.
    4. Jim Clark, a prof at Stanford, made a 12-stage pipeline using 12 copies of the same chip, and then left Stanford to found SGI.
      1. Later he bankrolled Netscape and 2 other companies.
      2. More recently he had the world's 4th largest yacht.
  3. 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 step-by-step derivations by transforming slow and clear programs to fast and obscure programs.

  4. My note on Two polygon filling algorithms.

  5. Curves are the next chapter of Angel. WebGL does this worse than full OpenGL. Here is a summary. Big questions:

    1. What math to use?
    2. How should the designer design a curve?
    3. My notes on Bezier curves.
  6. Partial summary:

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

    2. Use connected strings or segments of low-degree curves, not one hi-degree curve.

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

    4. That requires at least cubic equations.

    5. Higher degree equations are rarely used because they have bad properties such as:

      1. less local control,
      2. numerical instability (small changes in coefficients cause large changes in the curve),
      3. roundoff error.
    6. See my note on Hi Degree Polynomials.

    7. 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\).

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

    9. 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.

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

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

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

    13. 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.

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

    15. 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.

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

    17. This is called a B-spline.

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

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

    20. 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.

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

    22. 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.

    23. 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) Non-uniform. (The knots are the values of the parameter for the joints.)

    24. Putting all this together gives a non-uniform rational B-spline, or a NURBS.

    25. A B-spline surface is a grid of patches, each a bi-cubic parametric polynomial.

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

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

    28. The surface math is an obvious extension of the curve math.

      1. \(x(u,v) = \sum_{i=0}^3\sum_{j=0}^3 a_{ij} u^i v^j\)
      2. \(y, z\) are similar.
      3. 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.
  7. My extra enrichment info on Splines.

  8. The program I showed yesterday is robotArm is Chapter 9.

  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.

  10. On Monday I'll start using the iClicker again, so bring yours.

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

  12. 14_1 Curves and surfaces.