CG ECSE-4750 Computer Graphics Midterm Solution, RPI, Thurs 2018-10-11

Name, RCSID: WRF solutions, frankwr (25 min)

Rules:

  1. You have 80 minutes.
  2. You may bring in one 2-sided 8.5"x11" paper with notes.
  3. You may not share material with each other during the exam.
  4. No collaboration or communication (except with the staff) is allowed.
  5. There are 20 questions. Check that your copy of this test has all seven pages.
  6. If you need more space, use the back of another page, and write a note in the original space to tell us.
  1. (2 pts) Suppose that you want to skew an object by adding each vertex's x-coordinate to the same vertex's y-coordinate. Where is the best place to do it?

    In the vertex shader.

  2. (2 pts) List the four components of the graphics pipeline in the correct order.

    vertex shader, primitive assembler, rasterizer, fragment shader

  3. (2 pts) What is the best type of variable for the location of a global light source in the vertex shader?

    Uniform

  4. (2 pts) If M is a 3D Cartesian rotation matrix, what property must the columns have?

    This: \(c_i \cdot c_j = \delta_{ij}\)

  5. (2 pts) Name the 2 types of shaders that every WebGL program must have.

    vertex and fragment shaders.

  6. (2 pts) What is the purpose of gl-canvas in this line of code:

    canvas = document.getElementById( "gl-canvas" );

    It's the id of an html canvas element that you want to draw into.

  7. (2 pts) What does this line of code do:

    gl.viewport( 0, 0, canvas.width, canvas.height );

    It sets the region of the canvas that you want to draw into, which is called the viewport, to be the whole canvas.

  8. (2 pts) What is the purpose of vPosition in this line of code?

    var vPosition = gl.getAttribLocation( program, "vPosition" );

    There are 2 different things called vPosition. On the right, the string is the name of an attribute variable in a vertex or fragment shader. On the left is a Javascript variable that will get the location of that shader variable in the GPU.

  9. (2 pts) Suppose that your vertex shader computed some property of each vertex and you want the rasterizer to compute a weighted value of that property for each fragment. What type of variable would your vertex shader store that property in?

    Varying.

  10. (2 pts) Consider an axis a=(1,0,0) and a point p=(2,4,3). What is the component of p that is perpendicular to a?

    (0,4,3)

  11. (2 pts) What Cartesian point corresponds to this 3D homogeneous point: (10, 9, 8, 7)?

    (10/7, 9/7, 8/7)

  12. (2 pts) This question is for 2D geometry. What is the homogeneous matrix for the perspective projection whose center is at Cartesian (0,0) and whose viewplane is x=2?

    The Cartesian equations will be x'=2, y'=2y/x.

    So, homogeneously: \(\begin{matrix}x'_h = 2 x_h \\ y_h'= 2 y_h\\ w= x_h \end{matrix}\) will do that. The matrix is: \(\begin{pmatrix}2&0&0\\0&2&0\\1&0&0\end{pmatrix}\)

  13. Of the explicit, parametric, and implicit curved surface equation types, which one or more makes it easy to test whether a given point is on the surface?

    Explicit and implicit.

    For parametric, you'd need to back solve for the parameter value, which is hard.

  14. (2 pts) Why does WebGL have the triangle-strip object type, in addition to the triangle type?

    With strips and fans, defining each triangle after the first requires only one vertex, instead of three. This saves space and i/o time.

  15. (2 pts) In the WebGL pipeline, the Primitive Assembler does what?

    It assembles sequences of vertex into triangles (or other primitives).

  16. (2 pts) You call gl.BufferSubData to do what?

    To replace part of a buffer in the GPU.

  17. (2 pts) What tool maps spectral colors into a human perceptual coordinate system? Use it to determine what one color a mixture of colors will appear to be. The curve of pure spectral colors was determined experimentally.

    CIE chromaticity diagram.

  18. (2 pts) What is the volume of a parallelepiped that starts at (0,0,0) and whose three edges starting from there are (1,0,0), (1,1,0), and (1,1,1)? It's ok to write the expression; no need to evaluate it.

    (1,0,0)x(1,1,0).(1,1,1). Permutations of this are also ok. I don't care if you get the sign wrong.

  19. (2 pts) Write the transformation equations to make a rectangle from (0,0) to (2,3) fit into a square that from (0,0) to (1,1). Scale the rectangle uniformly and center it in the square.

    s = 1/3.

    We want (1, 3/2) to map to (1/2, 1/2).

    So this: x' = 1/3 x + 1/6. y' = 1/3 y.

  20. (2 pts) You see the expression flatten(points) often in Javascript programs. what does flatten do?

    It removes the metadata info in the Javascript array points, which gives its size etc, to leave just a sequence of values.

End of midterm