CG Class 30, Wed 2018-12-12
Review before final exam.
Review before final exam.
Do you want a review in the Wed lab session?
Table of contents
Guha, the text I used before Angel, uses OpenGL. Angel uses WebGL.
OpenGL has a C API; WebGL uses Javascript.
That OpenGL is the obsolete version 2; WebGL is based on the current OpenGL 3.
OpenGL 2 has an immediate mode design: you draw things and they are forgotten.
In WebGL you send buffers to the GPU and then draw them.
OpenGL has compute shaders and geometry shaders. They fill in points along Bezier curves and draw trimmed NURBS.
A NURBS surface is a 2D parametric surface in 3D (or 4D if homogeneous).
A trim line is a 1D parametric curve in the the 2D parameter space of the surface.
The trim lines cut around the outside of the desired region and also cut out holes.
This is a powerful technique.
Table of contents
Before Angel, I used another book, Guha. It used old OpenGL in C. However therefore it could show NURBS. Some sample programs are in
https://wrf.ecse.rpi.edu/wiki/ComputerGraphicsFall2013/guha/Code
Look at bezierCurves, which shows moving control points.
trimmedBicubicSplineSurface shows NURBS.
Victor Calvert writes,
The WebGL report shows current-environment specifics, including the maximum number of textures, maximum framebuffer resolution, and other information, retrieved via the WebGL API.
(2 pts) Computing the effect of light reflecting off of one diffuse surface onto the other surfaces in the scene is called:
(2 pts) Painting a image onto a face to simulate fine detail is called:
(2 pts) Pretending to alter the normal vectors to the surface during rendering is called:
(2 pts) Quickly copying blocks of pixels from one buffer to another is called:
(2 pts) Reflecting the objects around a shiny object onto its surface is called:
Answer: slides 9_3.
(2 pts) Several coordinate systems are typically used in texture mapping. Which one may be used to model curves and surfaces?
(2 pts) Which one is used to identify points in the image to be mapped?
(2 pts) Which one is conceptually, where the mapping takes place?
(2 pts) Which one is where the final image is really produced?
Answers: slide 9_4_5.
(2 pts) Mathematically, the aliasing problem in CG
(2 pts) When you add many images together to blend them, there may be problems: (10_3)
(2 pts) Fog has been removed from OpenGL, and is not in WebGL, because: (10_3)
(2 pts) What does sampler2D do? (10_4)
(2 pts) Rendering a scene by computing which pixels are colored by each object is called (12_5)
(2 pts) Rendering a scene by computing which objects are behind each pixel is called (12_5)
(2 pts) Cohen-Sutherland clipping (13_1)
(2 pts) View normalization (13_1)
(2 pts) About polygon clipping: (13_2)
(2 pts) From his profits from SGI, Netscape, and other startups, Jim Clark bought the world's XXX largest yacht.
(2 pts) Which hidden surface algorithm sorts objects back-to-front? (13_2)
(2 pts) Which hidden surface algorithm preprocesses objects into a tree so that you can change the viewpoint and then render by traversing the tree in a different order? (13_2)
(2 pts) Which hidden surface algorithm might send its output straight to a display like a CRT w/o ever storing the whole image? (13_2)
(2 pts) Some colors that you can see on your display cannot be printed, and vv. Why? (13_4)
(2 pts) What is happening in the following code that is part of a picking program that we saw (11_4):
if(i==0) gl_FragColor = c[0]; else if(i==1) gl_FragColor = c[1]; else if(i==2) gl_FragColor = c[2]; else if(i==3) gl_FragColor = c[3]; else if(i==4) gl_FragColor = c[4]; else if(i==5) gl_FragColor = c[5]; else if(i==6) gl_FragColor = c[6];
(2 pts) Radiosity is better than ray tracing when the scene is all
(2 pts) Ray tracing is better than radiosity when the scene is all
(2 pts) Firing multiple rays through each pixel handles the problem of
(2 pts) Consider a 2D Cartesian cubic Bezier curve with these control points: (0,0), (0,1), (1,1), (1,0). What is the point at t=0? OK to look up the formula.
(2 pts) What is the point at t=1/2?
(2 pts) What is the point at t=1?
(2 pts) If you interpolate a curve through a list of control points instead of approximating a curve near the points, then what happens?
(2 pts) If you use quadratic Bezier curves, then what happens?
(Total: 64 points.)
Table of contents
We've seen some of this.
Curves are the next chapter of Angel. WebGL does this worse than full OpenGL. Here is a summary. Big questions:
Partial summary:
To represent curves, use parametric (not explicit or implicit) equations.
Use connected strings or segments of low-degree curves, not one hi-degree 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:
See my note on Hi Degree Polynomials.
One 2D cartesian parametric cubic curve segment has 8 d.f. in 2D (12 in 3D).
\(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. Designers like this.
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.
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.
Matching tangents (called \(G^1\) or geometric continuity) is sufficient, and is weaker than matching the 1st derivative (\(C^1\) or parametric continuity), since the 1st derivative has a direction (tangent) and a length. Most people do \(C^1\) because it's easier and good enough. However \(G^1\) gives you another degree of freedom to use in your design.
Similarly, matching the radius of curvature (\(G^2\) or geometric continuity) is weaker than matching the 2nd derivative (\(C^2\) or parametric continuity), but most people do parametric continuity.
Parametric continuity reduces each successive segment from 8 d.f. down to 2 d.f.
This is called a B-spline.
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).
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) Non-uniform. (The knots are the values of the parameter for the joints.)
Putting all this together gives a non-uniform rational B-spline, or a NURBS.
A B-spline surface is a grid of patches, each a bi-cubic 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.
My extra enrichment info on Splines.
The program I showed earlier is robotArm is Chapter 9.
To run program figure there, you may 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.
Table of contents
Here's my summary of problems with the main methods:
Table of contents
At this point we've learned enough WebGL. The course now switches to learn the fundamental graphics algorithms used in the rasterizer stage of the pipeline.
A lot of the material in the clipping slides is obsolete because machines are faster now. However perhaps the rendering is being done on a small coprocessor.
Big idea (first mentioned on Oct 20): Given any orthogonal projection and clip volume, we transform the object so that we can view the new object with projection (x,y,z) -> (x,y,0) and clip volume (-1,-1,-1) to (1,1,1) and get the same image. That's a normalization transformation'.
Table of contents