ECSE-4750 Computer Graphics, Rensselaer Polytechnic Institute, Final Exam B, 12 Dec 2013

NAME: _________WRF SOLUTION _______________EMAIL:__________________________ RIN:_________________________________

TOTAL: ___________/160


  • There are 40 questions. Answer them all. However, you may write free as the correct answer to any two questions.
  • Each question is worth 4 points.
  • There are 11 pages.
  • This exam is closed book; you may have two 2-sided letter-size note sheets. You may not use computers or communication devices, or share material with other students.

  1. ________ Does projection preserve angles? Justify your answer.
    No. For example, a square may project to a rectangle (in a parallel projection) or trapezoid (in a perspective projection). The angle that the diagonal makes with an edge is no longer 45 degrees.
  2. ________ When using 2D homogeneous coordinates, at what point do the lines x+y+w=0 and x+2y+3w=0 intersect?
    (1,-2,1)
  3. ________ Consider the triangle with Cartesian vertices (0,0,0), (1,0,0),(0,1,1). What is the normal to its surface? Your answer must be normalized.
    (0, -.7, .7) or (0, .7, -.7)
  4. ________ Here is a 2D homogeneous transformation matrix. Prove that it is, or is not, a rotation. If it is, then what is the angle of rotation?
    {$ \begin{pmatrix} 0 & -4 & 0 \\ 4 & 0 & 0 \\ 0 & 0 & 4 \end{pmatrix} $}
    Convert to a Cartesian 2x2 matrix. The determinant is -1, so it's not a rotation. Extra: It's a combo of a rotation and a reflection, which some people call an improper rotation.
  5. ________ Assume that one rotation is expressed as the quaternion j and that a 2nd rotation is the quaternion k. What is the quaternion for those two rotations in order combined?
    q = jk = i
  6. ________ What is its axis and angle?
    Axis = X axis = (1,0,0). Angle = 180 degrees.
  7. ________ Suppose that you want to move a robot arm along a path that is a spline curve. What is wrong with using a piecewise quadratic spline? Saying, "the curve looks bad", is not informative enough.
    Each piece is a quadratic Bezier curve and is planar. So, at each joint, the robot would suddenly have to switch from moving smoothly in one place to moving in another plane. IOW, its velocity would not be continuous. That's impossible for physical objects (unless it slowed to a stop at the joint).
    Consider these 4 types of lighting:
    • user-specified color at each vertex. n, n
    • user-specified ambient lights with amfbient material colors. n, n
    • user-specified diffuse lights with diffuse material colors. y, n
    • user-specified specular lights with specular material colors. y, y
  8. ______ For each of those say whether the color changes when only the light moves, by circling y or n in the first y / n group above.
  9. ______ For each of those say whether the color changes when only the camera moves, by marking the 2nd y / n group.
    Look at this shader program:
      uniform vec3 lightPos[3];
    varying vec3 N, L[3];
    
    void main(void)
    {
        // vertex MVP transform
        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    
        vec4 V = gl_ModelViewMatrix * gl_Vertex;
    
        // eye-space normal
        N = gl_NormalMatrix * gl_Normal;
    
        // Light vectors
        for (int i = 0; i < 3; i++)
            L[i] = lightPos[i] - V.xyz;
    
        // Copy the primary color
        gl_FrontColor = gl_Color;
    }
    
    
  10. ________ Is this a vertex shader or a fragment shader?
    It's a vertex shader since it refers to gl_Vertex.
  11. ________ Where does the variable gl_Vertex get its value?
    It's input from OpenGL program, perhaps set by glVertex.
  12. ________ Where does the variable lightPos get its value?
    It's imput from the OpenGL program, in which it will have been linked to a user variable.
  13. ________ Who uses the value of variable N after this shader finishes?
    The next stage in the pipeline. The next stage is typically the rasterizer or the Tesselation Control Shader.
  14. _______ In a shader, what does this code do: v.yxzw = v.xyzw ?
    It swizzles, that is, does a parallel assignment of 4 vector components.
  15. ______ Imagine a 2-D quadratric Cartesian Bezier curve with control points P0(0,0), P1(1,0), P2(0,1). What are the points on the curve with t=0, t=1/2, t=1?
    (0,0), (1/2, 1/4), (0,1)
  16. ______ Imagine a 2-D quadratric Cartesian Bezier curve with control points P0(0,0), P1(1,0), P2(0,1). Imagine that you are joining a 2nd Bezier curve to the end of this one, so that there is C1 continuity at the joint. What are the 1st and 2nd control points of this new curve?
    Q0(0,1), Q1(-1,2)
  17. ______ How many degrees of freedom would a 3D cubic homogeneous Bezier patch have?
    16 points with 4 coords gives 48 d.f.
  18. ______ Give 3 reasons why we usually use a sequence of low-degree curves instead of one high degree curve.
    The high degree curve: does not have local control, does not have as much of an intuitive relation between the control points and the curve, is more subject to numerical instability (loss of significant digits, roundoff error), is not necessary to achieve visible smoothness.
  19. ______ Give 1 reason why we use parametric curves instead of explicit curves.
    An explicit curve is single valued. If you rotated it, you'd have to cut it into pieces. A parametric curve can bend back onto itself, so this is not a problem.
  20. ______ What does the word Rational in NURBS mean?
    You compute cartesian coordinates as the ratio of homogeneous coords.
  21. ______ An evaluator is often used to generate vertex positions. Name 3 other things an evaluator might generate.
    Color, surface normal, texture coordinates.
  22. ______ A material's color is represented by 10 numbers. Name them.
    3 ambient color reflectivity components (R,G,B). 3 diffuse color components. 3 specular color components. Shininess exponent.
  23. ______ What coordinate system do you define a trim line in?
    In the parametric coordinate system of the patch that you're trimming.
  24. ______ The Bresenham line algorithm was devised to operate efficiently with (or without) what property of hardware?
    No floating point, and even multiplication was expensive.
  25. ______ What might clipping do to the number of vertices?
    1. The number of vertices might stay the same or reduce but not grow.
    2. The number of vertices might stay the same or grow but not reduce.
    3. The number of vertices might stay the same or grow or reduce.
    4. The number of vertices must stay the same.
  26. ______ What is a texture sampler, and how is it more powerful than an array?
    You input coordinates and output a color. More powerfully than an array, if the coordinates are not exactly at a texel, the sampler interpolates as necessary, using the rule that you specified, e.g., nearest, perhaps even between mipmap levels.
  27. ______ If you want to create a highlight in the middle of a triangle, can you do that by computing the color at each vertex and interpolating (rastering) the color across the triangle? Justify your answer.
    No because linear interpolation creates values inside the triangle that are never more than the brightest vertex.
  28. ______ What happened to immediate mode in the current OpenGL? Why?
    It was removed. Repeatedly sending the data to the GPU is too slow, so now we store data in the GPU in buffer objects. Implementing immediate mode takes effort.
  29. ______ What does Primitive Assembly mean?
    Assembling groups of vertices into higher objects, e.g., lines, triangles, or patches.
  30. ______ What does this do: glBindBuffer(GL_ARRAY_BUFFER, buffer[VERTICES]);
    It binds the buffer object name buffer[VERTICES], which you got with glGenBuffers, so that it will contain vertex array data.
  31. ______ What does this do: glBufferData(GL_ARRAY_BUFFER, sizeof(vertices) + sizeof(colors), NULL, GL_STATIC_DRAW);
    It creates a buffer object, whose name you had reserved with glGenBuffers, with sizeof(vertices) + sizeof(colors) bytes reserved. The application will set the once data later, and the data will be used for drawing.
  32. ______ What does this do: glLinkProgram(programId);
    It links a program object (that runs on the GPU) incorporating any shaders that you have attached to it, to create an executable that will run on the shaders.
  33. ______ What does this do: glEnableClientState(GL_VERTEX_ARRAY);
    Sets a flag so that future calls to glDrawArrays etc will use the vertex position information that you earlier specified in a vertex array.
  34. ______ What does this do: glColorPointer(3, GL_FLOAT, 0, colors);
    It specifies an array of colors, called colors, which the system will use in the future. Each color is 3 floats. There is no other data interleaved between the colors.
  35. ______ What does this do: glMatrixMode(GL_MODELVIEW);
    Says that any future call that affects a matrix will affect only the modelview matrix.
  36. ______ What does this do: glClearColor(1.0, 1.0, 1.0, 0.0);
    Says that when you clear the color buffer in future, it will be cleared to white.
  37. ______ What does this do: glDrawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_INT, stripIndices);
    Draws a triangle strip with 10 vertices whose numbers are listed in the stripIndices array, which is unsigned ints. The numbers are indexed into a vertex array earlier specified perhaps with glVertexPointer.
  38. ______ What does this do: programId = glCreateProgram();
    It creates an empty program object, which you will later attach shaders to, link, etc.
  39. ______ Why is it inefficient to do computations in the display routine that could be done at initialization time.
    You're doing the computation many times instead of once.
  40. ______ What does this do:
    <body onload="webGLStart(); resizeCanvas(600); flipAnim()">
    In an HTML page, it defines a javascript callback to be called when the page is loaded. The listed routines initialize webgl, set the canvas size and set a flag that the webgl program will use.

END