# CG Grade computation, Wed 2017-12-20

1. Normalize each homework to have the same number of points.

2. Add the top 6 homeworks, and normalize to 25%.

3. Normalize midterm to 25%.

4. For term project: project itself, writeup and video, is normalized to 80%. Two progress reports are each 10%. Add them to make 100% for the project.

5. Normalize that project score to 25%.

6. Normalize final exam to 25%.

7. Add normalized homeworks, midterm, project, final to make 100%.

8. Add knowitall points (7 students got total 10 points).

9. Ameliorate the grade cutoffs listed in the syllabus by 2 points. E.g., A is >=93.0.

Min        Letter  Count
0  FF      2
48 DD      0
53 DP      0
58 CM      0
63 CC      3
68 CP      1
73 BM      8
78 BB      13
83 BP      13
88 AM      8
93 AA      5

10. Final-exam [Total Pts: 60]: 56 56 56 56 56 55 55 55 54 54 54 54 54 54 54 53 53 52 52 52 51 51 51 50 50 50 49 49 49 49 49 49 48 48 47 46 46 45 45 44 44 43 43 42 41 40 40 38 36 35 29 27 24 8

11. Course total [Total Pts: 100] 96.8 95.1 95.0 94.9 94.0 92.4 91.5 91.3 91.1 90.7 90.4 89.3 88.9 88.0 87.8 87.5 86.6 86.4 85.6 84.6 84.4 84.2 84.2 84.1 83.7 83.4 82.3 81.9 81.8 81.4 80.2 80.0 79.8 79.4 79.3 78.7 78.6 78.2 78.1 77.8 77.6 77.0 76.5 74.8 74.3 73.6 73.3 71.6 66.9 65.8 63.9 43.0 38.4 35.3 34.9 31.6 30.6 26.6 25.5

# CG ECSE-4750 Computer Graphics Final Exam Solution, RPI, Mon 2017-12-18

Name, RCSID:

WRF solutions

Rules:

1. You have 180 minutes.
2. You may bring in two 2-sided 8.5"x11" papers 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 30 questions. Check that your copy of this test has all the pages.

Questions:

1. _____/2 Put these graphics pipeline components in the correct order:

2. primitive-assembly
3. rasterizer

2. primitive-assembly
3. rasterizer
2. _____/2 If you do not tell OpenGL to do hidden surface removal, and depth buffer is not in use, and two objects overlap the same pixel, then what color is that pixel?

1. OpenGL throws an error.
2. the closer object
3. the farther object
4. the first object to be drawn there
5. the last object to be drawn there

1. the last object to be drawn there
3. _____/2 What is the purpose of vNormaljs in this line of code?

var vNormaljs = gl.getAttribLocation( program, "vNormal" );

It's the name of a shader attribute variable. getAttribLocation returns its location.

4. _____/2 There is an aliasing problem when raytracing objects that are so small that one ray sent through the center of a pixel might go to the left of the object, and the next ray, through the center of the next pixel, go to its right. Give two ways to modify ray tracing to lessen this problem.

1. randomize the position of the ray in each pixel.
2. fire several rays through each pixel and average.
5. _____/2 Bezier curves do not generally go through the their control points, except for the first and last control points. It would be quite easy to design a curve fitting system so that the curve goes through all the control points. However the CAD community has decided that they don't want this. Why?

The curve will swing outside the control polygon by a nonintuitive amount.

6. _____/2 In a fragment shader, a sampler2D does something more than a simple array lookup like you have in most programming languages. What?

When the subscript is fractional, this will interpolate between the values of the adjacent texels.

7. _____/2 Tell me about view normalization. What is it? What is good about it?

Transforms the universe, including the object, clip region, and projection, to make the clip region a 2x2x2 cube and the projection (x,y,z) -> (x,y,0).

Clipping and projection are now easier.

8. (2 pts) The last big update in the OpenGL standard removed many things from the standard. Name two things that we've discussed in class that we now have to implement ourselves if we wish to use.

Lighting. Fog. Etc.

9. _____/2 Consider this 2D homogeneous point: (2,3,4). Rotate it by 90 degrees. What is the resulting point, in a Cartesian representation?

Cart: (1/2, 3/4). Cart rotation matrix: (0, -1 ; 1, 0). Rotated point: (-3/4, 1/2).

10. _____/2 What is the 3x3 2D homogeneous matrix for a rotation by 90 degrees?

(0, -1, 0 ; 1, 0, 0; 0, 0, 1)

11. _____/2 Compute the projection equations when the viewpoint is at (0,0,0) and the projection plane is x+2y+2z=4. Use Cartesian coordinates. You do not need to put the result into a matrix form, but simplify your result as much as possible.

Projected point is a scaled version of input point.

x' = x * 4/ (x+2y+2z)

y' = y * 4/ (x+2y+2z)

z' = z * 4/ (x+2y+2z)

12. _____/2 Using homogeneous coordinates for spline control points gives the designer an extra tool. What happens to the curve when the designer changes the weight in a homogeneous control point?

That attracts the nearby part of the curve closer to that point.

13. _____/2 Why are the Bresenham line and circle drawing algorithms less useful now?

Now, HW is faster and has floating point.

14. _____/2 In the graphics pipeline, when a triangle is processed, the (x,y,z) coordinates of the vertices are interpolated across the whole triangle to give the coordinates of each fragment. Name two other things that may commonly be specified at the vertices and then interpolated across the triangle to give a value for each fragment.

Normals, texture coordinates, colors.

15. _____/2 Given a=(3, 4, 5) compute a matrix M so that, for any p, (a ⋅ p) a = M p

Mij = ai*aj.

M = (9 12 15; 12 16 20; 15 20 25)

16. _____/2 Before memory was cheap enough for depth buffers to be practical, one hidden surface technique involved sorting the objects by distance and then drawing them into the color buffer back-to-front.

1. Name this method.

Painters algorithm.

2. Describe one complexity with implementing it.

When 2 objects have close Z values, it's impossible to tell which to draw first. A really bad case is 3 interlocking objects.

17. _____/2 In a shader, what is the difference between a uniform variable and a varying variable?

Uniform: same value for all vertices. E.g., light position.

Varying: computed in vertex shader. Interpolated by rasterizer. Input to fragment shader. E.g. color.

18. _____/2 In this code to compute diffuse lighting:

float intensity = max(0.0, dot(N, normalize(L)));

where is the light source when max makes a difference?

Behind face.

19. _____/2 Given a sphere of radius one, what's the normal to the surface at the point (0,0,1)?

(0,0,1)

20. _____/2 3D clipping is usually implemented with six stages of a viewing pipeline. What are those 6 stages?

Clip against a top plane, bottom plane, front plane, back plane, left plane, then right plane. (Order doesn't matter).

21. _____/2 What causes some people to be tetrachromats?

Two different versions of the green cone, most sensitive to 2 different wavelengths, gene on two X chromosones.

22. _____/2 Give 2 reasons why we usually use a sequence of low-degree curves instead of one high degree curve.

Local control.

More numerically stable (less roundoff error).

Curve is more intuitive - small control point changes don't cause big curve changes.

23. _____/2 What does the word rational mean in NURBS?

homogeneous.

24. _____/2 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.

The number of vertices might stay the same or grow or reduce.

25. _____/2 What is the difference between Phong shading and Gouraud shading?

Phong: input: normal at each vertex. interpolate them for each fragment. compute lighting at each fragment.

Gouraud: input: normal at each vertex. compute lighting at each vertex. Or, input lighting at each vertex. interpolate lighting for each fragment.

Gouraud faster but not as realistic.

26. _____/2 What does it mean to separate the geometry from the topology when building a model?

geometry is the vertex position.

topology is which vertices define each edge and face.

separate means to store them in separate arrays. Each vertex is stored only once.

27. _____/2 Can the volume of a small cube change when its vertices are rotated? (yes or no). Why (not)?

No since lengths don't change since rotations are rigid.

28. _____/2 What does this do:

gl.vertexAttribPointer( vNormal, 3, gl.FLOAT, false, 0, 0 );

Tells GPU that the array of bytes storing the vertex normals is to be interpreted as groups of 3 floats per normal. vNormal is the address of the shader attribute variable for the normal.

29. _____/2 What does this JS line do?

document.getElementById("ButtonX").onclick = function(){axis = xAxis;};

defines a callback for a button.

30. _____/2 Where is the 3D homogeneous1point (1,0,0,0)?

at infinity in the direction (1,0,0).

End of final exam

# CG ECSE-4750 Computer Graphics Final Exam, RPI, Mon 2017-12-18

Name, RCSID:

.

.


Rules:

1. You have 180 minutes.
2. You may bring in two 2-sided 8.5"x11" papers 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 30 questions. Check that your copy of this test has all the pages.

Questions:

1. _____/2 Put these graphics pipeline components in the correct order:

2. primitive-assembly
3. rasterizer
.

.

2. _____/2 If you do not tell OpenGL to do hidden surface removal, and depth buffer is not in use, and two objects overlap the same pixel, then what color is that pixel?

1. OpenGL throws an error.
2. the closer object
3. the farther object
4. the first object to be drawn there
5. the last object to be drawn there
.

.

3. _____/2 What is the purpose of vPosition in this line of code?

var vNormaljs = gl.getAttribLocation( program, "vNormal" );

.

.

4. _____/2 There is an aliasing problem when raytracing objects that are so small that one ray sent through the center of a pixel might go to the left of the object, and the next ray, through the center of the next pixel, go to its right. Give two ways to modify ray tracing to lessen this problem.

.

.

5. _____/2 Bezier curves do not generally go through the their control points, except for the first and last control points. It would be quite easy to design a curve fitting system so that the curve goes through all the control points. However the CAD community has decided that they don't want this. Why?

.

.

6. _____/2 In a fragment shader, a sampler2D does something more than a simple array lookup like you have in most programming languages. What?

.

.

7. _____/2 Tell me about view normalization. What is it? What is good about it?

.

.

8. (2 pts) The last big update in the OpenGL standard removed many things from the standard. Name two things that we've discussed in class that we now have to implement ourselves if we wish to use.

.

.

9. _____/2 Consider this 2D homogeneous point: (2,3,4). Rotate it by 90 degrees. What is the resulting point, in a Cartesian representation?

.

.

10. _____/2 What is the 3x3 2D homogeneous matrix for a rotation by 90 degrees?

.

.

11. _____/2 Compute the projection equations when the viewpoint is at (0,0,0) and the projection plane is x+2y+2z=4. Use Cartesian coordinates. You do not need to put the result into a matrix form, but simplify your result as much as possible.

.

.

12. _____/2 Using homogeneous coordinates for spline control points gives the designer an extra tool. What happens to the curve when the designer changes the weight in a homogeneous control point?

.

.

13. _____/2 Why are the Bresenham line and circle drawing algorithms less useful now?

.

.

14. _____/2 In the graphics pipeline, when a triangle is processed, the (x,y,z) coordinates of the vertices are interpolated across the whole triangle to give the coordinates of each fragment. Name two other things that may commonly be specified at the vertices and then interpolated across the triangle to give a value for each fragment.

.

.

15. _____/2 Given a=(3, 4, 5) compute a matrix M so that, for any p, (a ⋅ p) a = M p

.

.

16. _____/2 Before memory was cheap enough for depth buffers to be practical, one hidden surface technique involved sorting the objects by distance and then drawing them into the color buffer back-to-front.

1. Name this method.
2. Describe one complexity with implementing it.
.

.

17. _____/2 In a shader, what is the difference between a uniform variable and a varying variable?

.

.

18. _____/2 In this code to compute diffuse lighting:

float intensity = max(0.0, dot(N, normalize(L)));

where is the light source when max makes a difference?

.

.

19. _____/2 Given a sphere of radius one, what's the normal to the surface at the point (0,0,1)?

.

.

20. _____/2 3D clipping is usually implemented with six stages of a viewing pipeline. What are those 6 stages?

.

.

21. _____/2 What causes some people to be tetrachromats?

.

.

22. _____/2 Give 2 reasons why we usually use a sequence of low-degree curves instead of one high degree curve.

.

.

23. _____/2 What does the word rational mean in NURBS?

.

.

24. _____/2 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.
.

.

25. _____/2 What is the difference between Phong shading and Gouraud shading?

.

.

26. _____/2 What does it mean to separate the geometry from the topology when building a model?

.

.

27. _____/2 Can the volume of a small cube change when its vertices are rotated? (yes or no). Why (not)?

.

.

28. _____/2 What does this do:

gl.vertexAttribPointer( vNormal, 3, gl.FLOAT, false, 0, 0 );

.

.

29. _____/2 What does this JS line do?

document.getElementById("ButtonX").onclick = function(){axis = xAxis;};

.

.

30. _____/2 Where is the 3D homogeneous1point (1,0,0,0)?

.

.


End of final exam

# CG Class 35, Wed 2017-12-13

Student videos, part 2/2.

# CG Class 34, Mon 2017-12-12

Student videos, part 1/2.

# CG Class 32, Mon 2017-12-04

## 1   Spring parallel computing course

ECSE-4740 Engineering Parallel Computing welcomes students wanting to learn state-of-the-art parallel computing facilities that is also affordable. That is, multicore Intel Xeon and Nvidia GPU.

Qualified students from any department are welcome. You will learn things that will be useful in your work.

## 2   Term project videos

Per the syllabus, one deliverable for your term project is a 3-minute video to be shown in class.

1. This is one video per team.
2. The actual length can be anywhere from 2 to 3 minutes.
3. The class days are next Mon at 4 in DCC and next Wed at 6 in the lab.
4. We will show up to 20 videos per day.
5. If you prefer one day to the other, then email both Mou and Qiushi with your choice. First come, first served.
6. Make the subject of your email CG Term Project Video Schedule.
7. Send one email per team, and mention everyone's name.
8. Email your video (or a downloadable link to it) to both Mou and Qiushi by the end of Dec 8. (This is a day later than the date in the syllabus.) They will combine them into one dir available for showing.
9. Please ensure that your video is easy to play; we have 4 minutes per video including setup time, showing, and questions.
10. I look forward to seeing what fun things people have done.
11. What the video should cover:
1. show that the features your doc describes actually work.
2. show how to use it.
3. describe any difficulties you had.
4. describe major design decisions.

## 3   WebGL query

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.

## 4   Chapter 14 ctd

See notes from last class.

The last slide set we saw was 14_1.

Here.

# CG Class 31, Thurs 2017-11-30

## 1   Spring parallel computing course

ECSE-4740 Engineering Parallel Computing welcomes students wanting to learn state-of-the-art parallel computing facilities that is also affordable. That is, multicore Intel Xeon and Nvidia GPU.

Qualified students from any department are welcome. You will learn things that will be useful in your work.

## 2   Visibility methods

1. Painters:
1. The painter's algorithm is tricky when faces are close in Z.
2. Sorting the faces is hard and maybe impossible. Then you must split some faces.
3. However sometimes some objects are always in front of some other objects. Then you can render the background before the foreground.
2. Z-buffer:
1. Subpixel objects randomly appear and disappear (aliasing).
2. Artifacts occur when objects are closer than their Z-extent across one pixel.
3. This happens on the edge where two faces meet.
3. BSP tree:
1. In 3D, many faces must be split to build the tree.
4. The scanline algorithm can feed data straight to the video D/A. That was popular decades ago before frame buffers existed. It is popular again when frame buffers are the slowest part of the pipeline.
5. A real implementation, with a moving foreground and fixed background, might combine techniques.
6. References: wikipedia.

## 3   More comments on clipping

1. Many of these algorithms were developed for HW w/o floating point, where even integer multiplication was expensive.
2. Efficiency is now less important in most cases (unless you're implementing in HW).
3. The idea of clipping with a 6-stage pipeline is an important.
4. Jim Clark, a prof at Stanford, made a 12-stage pipeline using 12 copies of the same chip, and then left Stanford to found SGI.
1. Later he bankrolled Netscape and 2 other companies.
2. More recently he had the world's 4th largest yacht.

## 4   Chapter 13 slides ctd

1. My note on Bresenham Line and Circle Drawing. Jack Bresenham, then at IBM invented these very fast ways to draw lines and circles with only integer addition and subtraction. My note gives step-by-step derivations by transforming slow and clear programs to fast and obscure programs.

2. My note on Two polygon filling algorithms.

3. We've seen some of this.

## 5   Chapter 14

1. Curves are the next chapter of Angel. WebGL does this worse than full OpenGL. Here is a summary. Big questions:

1. What math to use?
2. How should the designer design a curve?
3. My notes on Bezier curves.
2. Partial summary:

1. To represent curves, use parametric (not explicit or implicit) equations.

2. Use connected strings or segments of low-degree curves, not one hi-degree curve.

3. If the adjacent segments match tangents and curvatures at their common joint, then the joint is invisible.

4. That requires at least cubic equations.

5. Higher degree equations are rarely used because they have bad properties such as:

1. less local control,
2. numerical instability (small changes in coefficients cause large changes in the curve),
3. roundoff error.
6. See my note on Hi Degree Polynomials.

7. One 2D cartesian parametric cubic curve segment has 8 d.f.

$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$.

8. Requiring the graphic designer to enter those coefficients would be unpopular, so other APIs are common.

9. 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.

10. The generated curve starts at P0, goes near P1 and P2, and ends at P3.

11. The curve stays inside the control polygon, the convex hull of the control points. A flatter control polygon means a flatter curve.

12. 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.

13. 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.

14. The three methods (polynomial, Bezier, Hermite) are easily interconvertible.

15. 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.

16. That reduces each successive segment from 8 d.f. down to 2 d.f.

17. This is called a B-spline.

18. 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).

19. Moving one control point moves the adjacent few spline pieces. That is called local control. Designers like it.

20. 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.

21. Extending this from 2D to 3D curves is obvious.

22. 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.

23. 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.)

24. Putting all this together gives a non-uniform rational B-spline, or a NURBS.

25. A B-spline surface is a grid of patches, each a bi-cubic parametric polynomial.

26. Each patch is controlled by a 4x4 grid of control points.

27. When adjacent patches match tangents and curvatures, the joint edge is invisible.

28. The surface math is an obvious extension of the curve math.

1. $x(u,v) = \sum_{i=0}^3\sum_{j=0}^3 a_{ij} u^i v^j$
2. $y, z$ are similar.
3. One patch has 48 d.f. for Cartesian points, or 64 d.f. for homogeneous points, although most of those are used to establish continuity with adjacent patches.
3. My extra enrichment info on Splines.

4. The program I showed yesterday is robotArm is Chapter 9.

5. To run program figure there, you 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.

6. I have an Oculus Rift DK2, if anyone would like to borrow it. It's a little old but may be interesting.

7. Programs drawing the Utah teapot.

8. You do not need to learn most of those slides. Later I'll summarize what you need.

# CG Class 30, Mon 2017-11-27

## 1   Thanksgiving trivia questions

1. When the native American Squanto greeted the Pilgrims in March 1621, what language did he use?
2. Where had he learned it?

## 2   Videos

1. 3D Object Manipulation in a Single Photograph using Stock 3D Models (Siggraph 2014).

From here Photo-editing software restricts the control of objects in a photograph to the 2D image plane. We present a method that enables users to perform the full range of 3D manipulations, including scaling, rotation, translation, and nonrigid deformations, to an object in a photograph. As 3D manipulations often reveal parts of the object that are hidden in the original photograph, our approach uses publicly available 3D models to guide the completion of the geometry and appearance of the revealed areas of the object. The completion process leverages the structure and symmetry in the stock 3D model to factor out the effects of illumination, and to complete the appearance of the object. We demonstrate our system by producing object manipulations that would be impossible in traditional 2D photo-editing programs, such as turning a car over, making a paper-crane flap its wings, or manipulating airplanes in a historical photograph to change its story.

## 3   Chapter 12 slides ctd

1. 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.

## 4   Chapter 13 slides

1. 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'.