[ answers on web ]
Name: _______________________________
Student ID: _______________________________

Total points: 70
  1. What does it mean for a set of vectors to be linearly independent? [3]
    A set of vectors is linearly independent if no one vector in the set can be expressed as a linear combination of the other vectors. If we were to remove any vector from the set, then the vector space spanned by the set would collapse by a dimension.
  2. What are homogeneous coordinates, and how are they used in 3D computer graphics? [3]
    A consistent representation of both points and vectors. We add a fourth component, w, which is 0 for vectors and non-zero for points. Every (x,y,z,w), with w != 0, represents the 3D point (x/w, y/w, z/w). We apply transforms in homogeneous coordinates via 4x4 matrices; e.g., the model-view matrix.
  3. Describe the stages of the OpenGL rendering pipeline. There is some flexibility in how to divide the stages, but describe the operations that must happen to get from geometry (GL primitives) to what we see on screen. [6]
    (1) Vertex processing:
    Transform vertex and normal via model-view matrix, per-vertex lighting calculation (for Gouraud), projection matrix
    (2) Assembly/clipping:
    Connect vertices into primitives, view frustum culling, clip against view volume
    (3) Rasterizer:
    Convert into pixel grid, interpolate per-vertex values across the primitive
    (4) Fragment processing:
    Per-fragment calculations, textures
    (5) Blending:
    Hidden-surface removal (depth buffer) and blending, final output to framebuffer
  4. The two most important transform matrices in OpenGL are the model-view matrix and the projection matrix. Contrast the roles of these two matrices. [4]
    The model-view matrix transforms from world coordinates to camera coordinates: it specifies the location of objects in the virtual world relative to the camera. It is also what we use to position objects relative to each other. The projection matrix transforms from camera coordinates to screen coordinates: it converts from 3D points to 2D points.
  5. Contrast orthographic projection with perspective projection. [3]
    The projector lines in orthographic projection are all parallel, whereas the projector lines in perspective projection converge to a single point, the center of projection. Orthographic projection is equivalent to perspective projection with a center of projection infinitely far away. Perspective results in foreshortening: closer objects appear larger, farther objects appear smaller.
  6. Contrast clipping with culling. Why are they important? [4]
    Clipping:
    Removes primitives which are outside the clipping volume and the viewport, the rendered portion of the image plane. This may introduce new vertices for primitives which intersect the clipping planes.
    Culling:
    Removes primitives which are not visible, even though they may be within the viewport. For instance, back-face culling removes primitives that face away from the camera, which are generally not visible.
  7. The GLUT function glutSolidTeapot(1.0) renders a Utah Teapot with size 1, centred at the origin. We want to render the teapot with size 5.0, centred at the point (-1, 0, 2), and rotated counter-clockwise about its own y-axis by 30 degrees.
    1. Without changing the call to glutSolidTeapot(), write a block of C/C++ OpenGL code to accomplish this. (The parameter to glutSolidTeapot() is actually a size parameter, but I'm asking you not to use that for this question.) The exact naming/syntax of the functions is not as important as the ordering. [3]
        glTranslate3f( -1., 0., 2. );
        glRotatef( 30., 0.0, 1.0, 0.0 );
        glScalef( 5., 5., 5. );
        glutSolidTeapot(1.0);
        
    2. Write a single 4x4 matrix that converts from the coordinate system of the teapot (object coords) to the coordinate system of the world (world coords). Assume left multiplication; i.e., a point p in homogeneous object coords will be multiplied by this matrix M to get the world coords p' = M p. (Hint: construct 4x4s for each of the transforms, and multiply the matrices in the correct order. I will be lenient on minor mathematical errors as long as you show your work.) [4]
      5. * cos(30.) -sin(30.) 0 -1.
      sin(30.) - 5. * cos(30.) 0 0.
      0 0 5. 2.
      0 0 0 1
  8. Describe three representations of rotations in 3D that we talked about in class. What are pros/cons of each? [4]
    Euler angles:
    Three angles indicating amount of rotation about the x, y, and z axes, respectively. Order is important. Problems with gimbal lock.
    Axis-angle:
    Three numbers indicating a unit vector about which to rotate, and one number indicating angle of rotation about that axis. This is the format expected by glRotatef().
    Unit quaternion:
    Four numbers (as described in previous problem). Easy to derive from axis-angle representation. Easy to compose multiple rotations via quaternion multiplication.
  9. Name and describe the four terms in the OpenGL local illumination model. For each term, list what vectors, if any, are required to compute the term. [5]
    Ambient:
    Uniform light that shines everywhere. No vectors needed.
    Diffuse:
    Light that shines on a dull, non-shiny object. Need normal vector and vector to the light source.
    Specular:
    Highlights reflecting off a shiny object. Need view vector to camera and reflection vector.
    Emissive:
    Simulates a glowing object. No vectors needed.
  10. How many numbers are needed to specify completely all the material properties provided by OpenGL for an object? Describe them. [3]
    17 numbers: RGBA for each of ambient, diffuse, specular, and emissive colours, plus the shininess coefficient.
  11. Contrast Gouraud shading with Phong shading. Which is better and why? Describe a situation where the difference might be very pronounced. Which one is supported by the regular fixed-function OpenGL pipeline? [4]
    Gouraud:
    Lighting calculations done per-vertex; shaded vertex colours are then interpolated (rasterized) across the face of the polygon.
    Phong:
    Lighting calculations done per-fragment (per-pixel): more work, but more accurate.
    The default OpenGL pipeline only does Gouraud. On a large polygon with high shininess, the small specular highlight may lie in the middle of the polygon, missing all the vertices. In that case, Gouraud shading would miss the highlight altogether, whereas Phong shading would capture it.
  12. Describe bump mapping: what is its purpose and how does it achieve it? Describe an example situation where it might be useful.[4]
    Emulating bumpy surfaces without actually creating more geometry (more vertices). Uses a bump map texture to indicate displacement of the surface (in or out). Calculates how that displacement would perturb the normal vectors. Per-fragment Phong shading then calculates the shaded colour of each fragment using the perturbed normals. Example: orange.
  13. Describe the two kinds of shaders defined in GLSL. What is the purpose of each? What are their inputs and outputs? [5]
    Vertex shaders do per-vertex processing: coordinate transformation through model-view matrix; transform normals, generate per-vertex colours, generate texture coordinates, etc.
    Fragment shaders work after the rasterizer and do per-fragment (per-pixel or more) processing: in the default pipeline, fragment processors don't do anything (pass-through), but they can be used for bump-mapping, Phong shading, etc.
  14. In GLSL shader programs, global variables may be marked as uniform, attribute, or varying. What does each of these mean? For each kind of variable, describe whether it is read-only, writable, or inaccessible by each of the two kinds of shader programs. [6]
    uniform: constant over the primitive; e.g., texture object. Set by host application; read-only for shaders
    attribute: may be different for each vertex; e.g., normal vector. Read-only for vertex shader.
    varying: set by vertex shader and interpolated by rasterizer; read-only for fragment shader. e.g., normal (N) and light (L) vectors interpolated across fragment for Phong shading.
  15. What does it mean for a curve in 3D to be a cubic polynomial? How many floating-point numbers are needed to uniquely define a cubic polynomial in 3D? [5]
    A curve is parameterized by a single parameter, u. A curve in 3D is described parametrically by three functions, x(u), y(u), z(u). For a polynomial curve, these three functions are linear combinations of polynomials in u (i.e.: 1, u, u2, u3, ...). A cubic polynomial curve uses only polynomials up to and including u3. Each coordinate function uses four polynomial terms; hence the whole 3D cubic polynomial curve can be defined uniquely with just 12 numbers.
  16. What are blending functions for curves in 3D? [4]
    Many 3D curves can be defined as linear combinations of their control points. The blending functions describe how much each control point contributes to each point along the curve, running from one end of the curve to the other. The horizontal axis is the parameter u; the vertical axis is the relative weight of the control point. There is one blending function for each control point. [Bezier curves have the nice property that the blending functions are all between 0 and 1.]