## ECSE-4750 Computer Graphics, Rensselaer Polytechnic Institute, Final Exam, 13 Dec 2012

NAME: _______WRF Solution___________EMAIL:__________________________ RIN:_________________________________

Subtotal of questions 1-5:____________/40, 6-15:________/40, 16-22:________/40, TOTAL: ___________/120

• There are 30 questions. There are 7 pages. Each question is worth 4 points.
• You may mark FREE as the (correct) answer to any two questions.
• This exam is open book: you may use calculators and any paper books and notes that you brought with you. You may not use computers or communication devices, or share material with other students.

Math:

1. ________ Consider a cubic 3D Bezier curve with Cartesian control points P0(0,0,0), P1(8,8,8), P2(8,8,8), P3(0,0,0). Compute the point P for t=.5.
• The weights for t=1/2 are 1/8, 3/8, 3/8, 1/8.
• So P(1/2) = (6,6,6).
For the next 3 questions, use 2D homogeneous coordinates:
2. ________ What is the equation of the line through the points (0,0,3) and (1,0,1). Write your answer in the form ax+by+cw=0, giving numbers for a,b,c. Reduce a,b,c so that they have no common factors.
y=0.
3. ________ What is the equation of the line through the points (0,1,1) and (2,2,2)?
y-w=0
4. ________ What is the point where those 2 lines intersect?
• The 2 lines are parallel and horizontal.
• Points on the 1st line are (x,0,1) as {$x\rightarrow\infty$}.
• That is the same as {$(1,0,\epsilon)$} as {$\epsilon\rightarrow0$}.
• Points on the 2nd line are (x,1,1) as {$x\rightarrow\infty$}.
• That is the same as {$(1,\epsilon,\epsilon)$} as {$\epsilon\rightarrow0$}.
• The limit is (1,0,0).
5. ________ Consider the triangle with Cartesian vertices (0,0,0), (1,0,0),(0,1,0). What is the normal to its surface? Your answer must be normalized.
The plane is z=0 so the normal is (0,0,1).
6. ________ 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?
{$\left[ \begin{array}{ccc} 0 & -3 & 0 \\ 3 & 0 & 0 \\ 0 & 0 & 3 \end{array} \right]$}
• Reducing it to a Cartesian matrix gives {$\left[ \begin{array}{cc} 0 & -1 \\ 1 & 0\end{array} \right]$}
• That is clearly a rotation of 90 degrees. Compute that matrix and see that it matches.
7. ________ What is the quaternion for a 180 degree rotation about the X axis?
i
8. ________ What is the quaternion for a 180 degree rotation about the Y axis?
j
9. ________ What is the quaternion for the first rotation about followed by the second?
ji = -k
10. ________ What is its axis and angle?
cos t/2=0, sin t/2=-1. axis: (0,0,1), angle: 270 degrees

Graphics:
11. ________ 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? The curve looks bad is not acceptable here.
• The discontinuous 2nd derivative means a discontinuous acceleration, which will (try to) jerk the robot arm. That could damage it.
12. _______ Write the equations for the following projection: The camera is at (0,0,0). The projection plane is x+y+z=3. Use cartesian coordinates.
13. ________ Write the homogeneous 4x4 matrix for the above transformation.
• {$$\left( \begin{array}{cccc} 1 &0&0&0\\ 0&1&0&0\\ 0&0&1&0 \\ \frac{1}{3}&\frac{1}{3}&\frac{1}{3}&0 \end{array} \right)$$}
• equivalently {$$\left( \begin{array}{cccc} 3 &0&0&0\\ 0&3&0&0\\ 0&0&3&0 \\ 1&1&1&0 \end{array} \right)$$}
14. ________ When texture mapping for a scene with a perspective projection, it is usually not possible to create a single texture map whose texels will be the same size as pixels for all objects in the scene. Why?
• With a perspective projection, distant parts of the object scales down more than near parts. So, one screen pixel corresponds to more area of distant parts. That is one pixel corresponds to more texels of distant parts. That assumes that texels are the same size everywhere on the real object, which is usual.
15. ________ Suppose that you are writing a flight simulator, where we are looking at the scene from outside the airplane. One obvious technique is to render the background before rendering the airplane. Name this technique.
The painter's algorithm.
16. _______ Name the rendering technique where diffuse light bounces from object to object.
17. _______ Name the type of mapping that can have a shiny doorknob reflect its surroundings.
environment mapping.
18. _______ Name the type of mapping that combines a diffuse object color with a light texture.
Light mapping
19. ________ With view normalization,
1. Do distances change? Y.
2. Do angles change? Y.
3. Do straight lines stay straight? Y.
4. Do parallel lines stay parallel? N.
20. _______ It can happen that two objects appear to be the same color under incandescent light but differently colored under fluorescent light.
1. What are these color pairs called?
Metamers.
2. How can this happen?
• At some (or all) frequencies, the two objects are reflecting quite different amounts of light from each other. However, the apparent (red or green or blue) color is the integral of the product of the reflectivity at each wavelength times the light intensity at that wavelength times the eye's (red or green or blue) sensitivity at that wavelength. Various combos in functions can give the same output.
• Example: object one reflects only red and green, and will appear yellow under white light. Object two reflects only yellow, and will also appear yellow under white light. Under monochromatic red light, object one appears red, but object two appears black.

Opengl:
21. _______ Place these 3 steps in order from earliest to latest.
• fragment processing third
• rasterizing second
• vertex processing. first
22. ________ Consider these 4 types of lighting:
• user-specified color at each vertex. N, N
• user-specified ambient lights with ambient material colors. N, N
• user-specified diffuse lights with diffuse material colors. Y, N
• user-specified specular lights with specular material colors. Y, Y
1. 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.
2. For each of those say whether the color changes when only the camera moves, by marking the 2nd y/n group.
  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;
}


24. ________ Where does the variable gl_Vertex get its value?
• From vertex coordinates set in the OpenGL program. They might be set by calling glVertex, in a vertex array, by defining a NURBS, etc.
25. ________ Where does the variable lightPos get its value?
From a user variable in the OpenGL program that's been connected to it.
26. ________ Who uses the value of variable N after this shader finishes?
The rasterizer, which interpolates it across the polygon.
27. ________ What is this code doing? What is lightPos?
    uniformLoc = glGetUniformLocation(progObj, "lightPos");
if (uniformLoc != -1)
glUniform3fv(uniformLoc, 1, lightPos0Eye);


• It connects the OpenGL variable lightPos0Eye to the shader variable lightPos. lightPos gets its value from lightPos0Eye. (However info does not flow back the other way.)
28. _______ In a shader, what is the difference between a uniform variable and a varying variable?
• A uniform variable has a constant value as the shaders process different vertices and fragments. A varying variable is given a different value for each vertex. Then the rasterizer interpolates it for each fragment.
29. _______ In a shader, what does this code do: v.yxzw = v.xyzw ?
• It swizzles. In parallel, v.y = v.x; v.x = v.y; v.z and v.w don't change.
30. ________ In the following code, the 2nd line clearly defines a nurbs curve.
 gluBeginTrim(nurbsObject);
gluNurbsCurve(nurbsObject, 10, curveKnots, 2, curvePoints[0], 4, GLU_MAP1_TRIM_2);
gluEndTrim(nurbsObject);


1. What is this curve being used for?
To trim out a hole (or to define a curved region) on the patch.
2. The curve is being created from control points stored in curvePoints. In what coordinate space are those points defined?
The parametric coordinate space of the patch, typically using variables u and v.

END