Skip to main content

CG ECSE-4750 Computer Graphics Final Exam, RPI, Mon 2019-12-16

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 thirtytwo questions. Check that your copy of this test has all the pages.
  6. Each question is the same weight: five points.

Questions:

  1. Name two major features that were present in the previous major version of OpenGL that were removed from the current version.

    .
    
    
    
    
    
    .
    
  2. What is the Mach band effect in the retina?

    .
    
    
    
    
    
    .
    
  3. What technical advance enabled frame buffers?

    .
    
    
    
    
    
    .
    
  4. Give an application of the vector triple product in computer graphics.

    .
    
    
    
    
    
    .
    
  5. What is the tristimulus model?

    .
    
    
    
    
    
    .
    
  6. In class we said that LCD displays combine pixels that emit three colors: red, green, and blue. However some experimental displays now have four colors; they also have yellow. Why do you think researchers are experimenting with these displays? I said that combining red and green gives yellow, and so having a yellow emitter shouldn't add any new capability?

    .
    
    
    
    
    
    .
    
  7. What does the javascript function window.alert do?

    .
    
    
    
    
    
    .
    
  8. What is the physical principle underlying LCD?

    1. Fire an energetic electron at a rare earth atom and a photon of light is emitted.
    2. Plowing your family farm as a kid can suggest an way to invent electronic television.
    3. A solution of corkscrew shaped molecules can rotate polarized light.
    4. Putting your finger close to a capacitor can change its capacitance.
    5. If two coils of wire are close, then an alternating current in one can induce a current in the other.
  9. What is different about the wavelength of pure purple compared to pure red, green, or blue?

    .
    
    
    
    
    
    .
    
  10. Imagine that you're designing the specification of a picking routine. You're thinking about what to return when the user picks a particular pixel on the screen. Why is returning the line of code that colored that pixel insufficient?

    .
    
    
    
    
    
    
    
    .
    
  11. Double buffering solves which problem:

    1. producing stereo images
    2. low memory bandwidth
    3. remote debugging PCs
    4. displaying from a frame buffer while it's being updated
    5. optimizing scheduling two elevators as a group
  12. Homogeneous coords have several advantages compared to cartesian coords. Give three.

    .
    
    
    
    
    
    
    
    
    
    .
    
  13. What is one disadvantage of homogeneous coords compared to cartesian? (This takes creative thinking since we didn't mention it in class).

    .
    
    
    
    
    
    
    
    .
    
  14. Generally in engineering, when several solutions to the same problem exist, each is sometimes the best. This question is about 3D rotation. (i) What is particularly good about the vector formula? (ii) What is particularly good about the matrix formula? (iii) What is particularly good about Euler angles?

    .
    
    
    
    
    
    
    
    
    
    
    .
    
  15. What type of vertex shader variable has the same value for each vertex?

    1. uniform variable
    2. varying variable
    3. constant variable
    4. variable constant
    5. lighting variable
  16. Does the view normalization transformation preserve straight lines, angles, both, or neither?

    .
    
    
    
    
    
    
    
    .
    
  17. Quaternions: simplify (i+j)k.

    .
    
    
    
    
    
    
    
    .
    
  18. What is the purpose of v1 in this line of code?

    var v2 = gl.getAttribLocation( program, "v1" );

    .
    
    
    
    
    
    
    
    .
    
    .
    
    
    
    
    
    
    
    .
    
  19. If a 3x3 rotation matrix has eigenvalues \(1, -\frac{\sqrt{3}}{2}+\frac{1}{2}i, -\frac{\sqrt{3}}{2}-\frac{1}{2}i\), then what is the rotation angle (in degrees)?

    .
    
    
    
    
    
    
    .
    
  20. Give me a matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}1 \\ 3 \\ 4\end{pmatrix} \times p\) .

    .
    
    
    
    
    
    
    .
    
  21. What is the normalized surface normal to the plane x+2y+3z+4=0?

    .
    
    
    
    
    
    
    .
    
  22. What is the difference between Gouraud shading and Phong shading?

    .
    
    
    
    
    
    
    .
    
  23. What is mipmapping? What problem does mipmapping solve?

    .
    
    
    
    
    
    
    .
    
  24. Beer companies sometimes hand out free cardboard glasses, which have a simple grey filter over one eye. When you watch a commercial with them, you see, sort of, a stereo effect. What property of your vision is this exploiting?

    .
    
    
    
    
    
    
    .
    
  25. What does it mean to separate the geometry from the topology?

    .
    
    
    
    
    
    
    .
    
  26. Name the best visibility algorithm when frame buffers are too expensive or too slow.

    .
    
    
    
    
    
    
    .
    
  27. What type of hardware was the Bresenham algorithm designed to be efficient on?

    .
    
    
    
    
    
    
    .
    
  28. Why do you need at least cubic degree for splines, i.e., why is quadratic too low?

    .
    
    
    
    
    
    
    .
    
  29. What does local control mean when designing with splines?

    .
    
    
    
    
    
    
    .
    
  30. Name one thing that is omitted from WebGL but that is in full OpenGL.

    .
    
    
    
    
    
    
    .
    
  31. When designing a spline curve, how do you deliberately reduce the degree of continuity at a joint?

    .
    
    
    
    
    
    
    
    
    .
    
  32. Why is there now a movement in CAD away from NURBS and back to using just lots of little flat triangles?

    .
    
    
    
    
    
    
    .
    

CG ECSE-4750 Computer Graphics Final Exam, RPI, Mon 2019-12-16 Solution

Name, RCSID: WRF solutions, frankwr

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 thirtytwo questions. Check that your copy of this test has all the pages.
  6. Each question is the same weight: five points.

Questions:

  1. Name two major features that were present in the previous major version of OpenGL that were removed from the current version.

    Immediate mode, specific lighting routines, builtin modelview and projection matrices, ...

  2. What is the Mach band effect in the retina?

    Neurons in the retina seem to inhibit their neighbors, effecting a hi-pass filter.

  3. What technical advance enabled frame buffers?

    Big cheap DRAM

  4. Give an application of the vector triple product in computer graphics.

    Volume of a parellelpiped

  5. What is the tristimulus model?

    Most people's eyes have 3 types of color receptors.

  6. In class we said that LCD displays combine pixels that emit three colors: red, green, and blue. However some experimental displays now have four colors; they also have yellow. Why do you think researchers are experimenting with these displays? I said that combining red and green gives yellow, and so having a yellow emitter shouldn't add any new capability?

    They enable more vivid and spectrally pure colors covering a wider gamut. Increase money flowing to the display manufacturers.

  7. What does the javascript function window.alert do?

    Popup a box with a message, which needs to be dismissed by the user.

  8. What is the physical principle underlying LCD?

    1. Fire an energetic electron at a rare earth atom and a photon of light is emitted.
    2. Plowing your family farm as a kid can suggest an way to invent electronic television.
    3. A solution of corkscrew shaped molecules can rotate polarized light.
    4. Putting your finger close to a capacitor can change its capacitance.
    5. If two coils of wire are close, then an alternating current in one can induce a current in the other.
  9. What is different about the wavelength of pure purple compared to pure red, green, or blue?

    Pure purple is not a spectral color and does not have a wavelength. It's a mix of pure red and violet. It has a complementary pure spectral color - green.

  10. Imagine that you're designing the specification of a picking routine. You're thinking about what to return when the user picks a particular pixel on the screen. Why is returning the line of code that colored that pixel insufficient?

    That line of code might be in a routine called several times to draw the same object in different places. Think wheels on a car, or lug nuts on the wheels.

  11. Double buffering solves which problem:

    1. producing stereo images
    2. low memory bandwidth
    3. remote debugging PCs
    4. displaying from a frame buffer while it's being updated
    5. optimizing scheduling two elevators as a group
  12. Homogeneous coords have several advantages compared to cartesian coords. Give three.

    1. Translation is a matrix multiply.
    2. Projection also.
    3. A homogeneous spline can exactly represent a circle.
    4. Points at infinity are representable, so parallel and perspective projections are essentially the same.
    5. You can change control points' weights.
  13. What is one disadvantage of homogeneous coords compared to cartesian? (This takes creative thinking since we didn't mention it in class).

    They take more space. That may require more time.

  14. Generally in engineering, when several solutions to the same problem exist, each is sometimes the best. This question is about 3D rotation. (i) What is particularly good about the vector formula? (ii) What is particularly good about the matrix formula? (iii) What is particularly good about Euler angles?

    1. vector: easily computable from the intuitive axis-angle representation.
    2. matrix: can combine them into one matrix, efficiently executes on current HW.
    3. Euler: matches how mechanical gyroscopes with nested gimbals function.
  15. What type of vertex shader variable has the same value for each vertex?

    1. uniform variable
    2. varying variable
    3. constant variable
    4. variable constant
    5. lighting variable
  16. Does the view normalization transformation preserve straight lines, angles, both, or neither?

    Straight lines but not angles.

  17. Quaternions: simplify (i+j)k.

    = ik+jk = -j + i

  18. What is the purpose of v1 in this line of code?

    var v2 = gl.getAttribLocation( program, "v1" );

    It's the name of an attribute variable in a shader program. (v2 in the javascript program will get its address so thast v1 can be accessed.)

  19. If a 3x3 rotation matrix has eigenvalues \(1, -\frac{\sqrt{3}}{2}+\frac{1}{2}i, -\frac{\sqrt{3}}{2}-\frac{1}{2}i\), then what is the rotation angle (in degrees)?

    \(\cos \theta = -\frac{\sqrt{3}}{2}\) so \(\theta=150\)

    -150 is also acceptable, because you could simultaneously negate the axis and angle.

  20. Give me a matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}1 \\ 3 \\ 4\end{pmatrix} \times p\) .

    \(\begin{pmatrix} 0 & -4 & 3\\ 4 & 0 & -1\\-3 & 1 & 0 \end{pmatrix}\)

  21. What is the normalized surface normal to the plane x+2y+3z+4=0?

    \(\frac{(1,2,3)}{\sqrt{14}}\)

  22. What is the difference between Gouraud shading and Phong shading?

    Gouraud computes the shading at each vertex of a face. The shading is bilinearly interpolated at each pixel (fragment) in the face.

    Phong shading computes the normal at each vertex, which is interpolated at each fragment. Then, at each fragment, that interpolated normal is normalized and used to compute the shading at each pixel. This can generate a highlight inside the face, which Gouraud shading cannot. However it is slower.

  23. What is mipmapping? What problem does mipmapping solve?

    A hierarchy of ever coarser (successively averaged) texture maps, with every bigger texels. This lets you pick texels that are close in size to the pixels, even as the face's projected size changes. This improves the image quality.

  24. Beer companies sometimes hand out free cardboard glasses, which have a simple grey filter over one eye. When you watch a commercial with them, you see, sort of, a stereo effect. What property of your vision is this exploiting?

    You see bright objects more quickly. It's as if the retina needs a certain amount of light to see an object. Therefore a dim object will be seen more quickly by the eye w/o the grey filter. If bright and dim objects are moving, this can be exploited to give an illusion of depth.

  25. What does it mean to separate the geometry from the topology?

    geometry: vertex positions. topology: which vertices are at the ends of the edges. Represent the edges by the ids of its vertices, not by the vertices coords. Store them separately. Now, each vertex's coords are stored only once even if the vertex is in several edges. It's easier to move the vertices, and lowers the chance of an inconsistency.

  26. Name the best visibility algorithm when frame buffers are too expensive or too slow.

    Scan line.

  27. What type of hardware was the Bresenham algorithm designed to be efficient on?

    HW with no floating point and slow int mult and division.

  28. Why do you need at least cubic degree for splines, i.e., why is quadratic too low?

    Quadratic can't match curvature at a joint. A quadratic bezier curve lies in a plane, but we want curves that are general in space.

  29. What does local control mean when designing with splines?

    Moving one control point moves only a local region of the spline.

  30. Name one thing that is omitted from WebGL but that is in full OpenGL.

    3D texture maps. compute shaders. NURBS.

  31. When designing a spline curve, how do you deliberately reduce the degree of continuity at a joint?

    Make two or more control point identical.

  32. Why is there now a movement in CAD away from NURBS and back to using just lots of little flat triangles?

    Additive manufacturing (3D printing) doesn't naturally do curves, unlike lathes. NURBS have problems, like non watertight models when the trim lines on two intersecting surfaces are not identical. Triangles are simpler. So, although lots of little triangles isn't perfect, some people like it better.

finished in 30 min

CG Class 27, Mon 2019-12-09

4   Term project optional demo

Airas will grade the projects. However, if you'd like to give me an optional 15-minute demo, then we can do that on Wed Dec 11 from 2pm on. A poorly prepared demo will hurt your grade.

5   After the semester

I'm open to questions and discussions about any legal ethical topic. Even after you graduate.

Good luck with your future work. Maybe your photo might be on a DCC window one day.

6   Review?

Would you like a review session in the regular lab time Wed Dec 11 at 6?

CG Class 26, Thu 2019-12-05

3   OpenGL in Guha vs WebGL in Angel

  1. Guha, the text I used before Angel, uses OpenGL. Angel uses WebGL.

  2. OpenGL has a C API; WebGL uses Javascript.

  3. That OpenGL is the obsolete version 2; WebGL is based on the current OpenGL 3.

  4. OpenGL 2 has an immediate mode design: you draw things and they are forgotten.

    In WebGL you send buffers to the GPU and then draw them.

  5. OpenGL has compute shaders and geometry shaders. They fill in points along Bezier curves and draw trimmed NURBS.

  6. A NURBS surface is a 2D parametric surface in 3D (or 4D if homogeneous).

    A trim line is a 1D parametric curve in the the 2D parameter space of the surface.

    The trim lines cut around the outside of the desired region and also cut out holes.

    This is a powerful technique.

4   Chapter 15 slides

  1. You do not need to learn most of those slides. Later I'll summarize what you need.
  2. 15_1 Global rendering.
  3. 15_2 Ray tracing.
  4. 15_3 What's next?.

CG Class 25, Mon 2019-11-25

1   Splines ctd

My extra enrichment info on Splines.

3   Old OpenGL in C and with NURBS

Before Angel, I used another book, Guha. It used old OpenGL in C. However therefore it could show NURBS. Some sample programs are in

https://wrf.ecse.rpi.edu/wiki/ComputerGraphicsFall2013/guha/Code

Look at bezierCurves, which shows moving control points.

trimmedBicubicSplineSurface shows NURBS.

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

CG Homework 9 solution

  1. (10 pts) Look at Figures 6.37 and 6.38 on pages 310 and 311 of the textbook. Write 50-100 words on why they look different.

    The first figure is rendering flat triangles. The JS program computes the true normals at the vertices of each triangle. Since the triangle is flat, the three normals are the same. They're sent to the vertex shader to compute the shading. So, each triangle is all the same shading, and is clearly different from its neighboring triangles.

    The second figure uses the fact that the triangles are an approximation to a sphere. The normals at the triangle vertices are the true normals to the sphere. So, the vertex shader computes different shades for each vertex of a triangle and that gets interpolated throughout the triangle. Thus the triangles are smoothly shaded and adjacent triangles have the same shading on their common edge.

  2. (10 pts) Look at Figure 6.39 on page 314 of the textbook. What is it about the spheres that the global model looks different from the local?

    The spheres can shadow each other. Ray tracing does this.

  3. (10 pts) Consider the sphere \(x^2+y^2+z^2=169\). What is the normal to the sphere at the point (-12,3,-4)? Be sure your normal is normalized.

    \(\frac{(-12,3,-4)}{\sqrt{144+9+16}} = (-12/13, 3/13, -4/13)\)

  4. (10 pts) Consider a block of glass with index of refraction 1.5. Some light is shining straight down on it. This is called normal incidence. How much of the light reflects off the glass and how much transmits into the glass? Hint: Use Fresnel's law.

    reflect: \(\left(\frac{1.5-1}{1.5+1}\right)^2 = 0.04\)

    transmit = .96

  5. (10 pts) A small light source that is twice as far away is 1/4 as bright. That is, there is an inverse square fall off for brightness. However, when modeling light in graphics, we usually don't do that. Why?

    1. The effect is too harsh, with small very bright regions and large dark regions.
    2. Ambient light means that the total brightness falloff is less than quadratic.

(Total: 50 points.)

CG Class 24, Thur 2019-11-21

2   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. Changing one control point of a hi-degree curve changes the whole curve. Parts of the curve distant from that point may move a lot. This makes designing a desired curve impossible.
      2. numerical instability. Small changes in coefficients cause large changes in the curve, even if computations are exact.
      3. roundoff error. Computations are not exact.
    6. See my note on Hi Degree Polynomials.

    7. One 2D cartesian parametric cubic curve segment has 8 d.f. in 2D (12 in 3D).

      \(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. Designers like this.

    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. Matching tangents (called \(G^1\) or geometric continuity) is sufficient, and is weaker than matching the 1st derivative (\(C^1\) or parametric continuity), since the 1st derivative has a direction (tangent) and a length. Most people do \(C^1\) because it's easier and good enough. However \(G^1\) gives you another degree of freedom to use in your design.

    17. Similarly, matching the radius of curvature (\(G^2\) or geometric continuity) is weaker than matching the 2nd derivative (\(C^2\) or parametric continuity), but most people do parametric continuity.

    18. Parametric continuity reduces each successive segment from 8 d.f. down to 2 d.f.

    19. This is called a B-spline.

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

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

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

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

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

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

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

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

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

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

    30. 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 earlier is robotArm is Chapter 9.

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

3   Additive manufacturing (3D printing) and curves

  1. This section contains material that is too new for most (all?) textbooks.
  2. However I see that a big part of my job is to identify stuff like this for you.
  3. Nevertheless, I don't know everything here. If someone in class is more knowledgeable, please speak up.
  4. I learned some of this attending the International Meshing Roundtable in Buffalo in Oct.
  5. One reason for designing with curved surfaces like NURBS is that machine tools like lathes make curves.
  6. Also, rotating things like turbines rotate in curves.
  7. However, NURBS have always had some problems. E.g., exactly intersecting two surfaces is infeasible. You had to approximate the intersection curve separately on the two surfaces. Those two approximate curves were slightly different, and so the object wasn't completely watertight.
  8. Also, some desirable operations, like offset surfaces, were always impossible to do exactly.
  9. Now, additive manufacturing changes the game.
  10. It's not easier to manufacture curved surfaces.
  11. In fact, designing with flat faces, like triangles, is easier.
  12. So, designers may now design objects with millions of triangles.
  13. How do we handle objects that really want curves, like rotating objects? Use lots of small triangles.

CG Homework 7 solution

  1. (4 pts) Use the homogeneous matrix to project homogeneous points onto the plane 2x+3y+4z=5, with COP at the origin. What does the point (1,2,4,5) project to? Give the answer as a Cartesian point.

    Use https://wrf.ecse.rpi.edu/pmwiki/Main/HomogeneousCoords

    The plane is 2/5 x + 3/5 y + 4/5 z = 1. The matrix is

    \(M=\begin{pmatrix} 1 &0&0&0\\ 0&1&0&0\\ 0&0&1&0 \\ 2/5 &3/5&4/5&0 \end{pmatrix} =\begin{pmatrix} 5 &0&0&0\\ 0&5&0&0\\ 0&0&5&0 \\ 2 &3&4&0 \end{pmatrix}\)

    \(p_h'=\begin{pmatrix} 5 &0&0&0\\ 0&5&0&0\\ 0&0&5&0 \\ 2 &3&4&0 \end{pmatrix} \begin{pmatrix} 1\\2\\4\\5\end{pmatrix} = \begin{pmatrix} 5\\10\\20\\24\end{pmatrix} \implies p_c = \begin{pmatrix} 5/24 \\10/24 \\20/24 \end{pmatrix}\)

  2. (4 pts) Repeat the previous question with the COP changed to (1,1,1,1).

    The easy way is to translate \(p_c = (1/5, 2/5, 4/5)\) by (-1,-1,-1) to \(q_c=(-4/5, -3/5, -1/5), q_h=(4,3,1,-5)\), project to \(q_h'=(20,15,5,21). q_c'=(20/21, 15/21, 5/21)\), then translate the result by (1,1,1) to get (41/21, 36/21, 26/21).

  3. (6 pts) Do exercise 5.6 on page 272 of the text,

    This looks for the general solution to the previous question.

    Multiply the matrices to translate, project, and translate back.

    If the projection plane is ax+by+cz=1 and the center of projection is (d,e,f), then (if I did this right; I multiplied the matrices with Mathematica) the homogeneous projection matrix is

    \(\begin{pmatrix} 1+a d & b d & c d & -d (1+a d)-b d e-c d f\\ a e & 1+b e & c e & -a d e-e (1+b e)-c e f\\ a f & b f & 1+c f & -a d f-b e f-f (1+c f)\\ a & b & c & -a d-b e-c f \end{pmatrix}\)

  4. (6 pts) This question will take some thinking).

    Imagine that you have an infinitely large room illuminated by one infinitely long row of point lights. This figure shows a side view of the room.

    The lights are h above the floor and are 1 meter from each other. Assume that the ceiling above the lights is black and that no light reflects off of anything.

    An object at distance d from a light gets illuminated with a brightness \(\frac{1}{d^2}\).

    Each point on the floor is illuminated by all the lights, but more brightly by the closer lights.

    A point p directly below a light will be a little brighter than a point q halfway between two such points. That is the problem --- we want the floor (at least the part directly below the line of lights) to be evenly lit, at least within 1%.

    However, the higher the line of lights, the more evenly the floor will be lit.

    Your question is to tell us what is the minimum value for h so that the line of the floor below the line of lights is evenly lit within 10%.

    ../files/hw-lights.png

    E.g., the brightness at p is

    \(b_p=\sum_{i=-\infty}^{\infty} \;\; \frac{1}{\left(h^2+i^2\right)}\)

    There are various acceptable ways to solve this. Here is one.

    The brightness at q is

    \(b_q=\sum_{i=-\infty}^{\infty} \;\; \frac{1}{\left(h^2+(i+1/2)^2\right)}\)

    \(b_p = \pi \coth(\pi h)/h, b_q = \pi \tanh(\pi h)/h\)

    \(b_p / b_q = \tanh^2(\pi h) = .9\)

    \(\pi h = 1.818413, h = 0.5788\)

    Another way, if you don't know how to sum the formulae is to write a function to compute \(b_p/b_q\) numerically as a function of h (sum 1000 terms), plot it and look for the value of h.

(Total: 20 points.)

CG Syllabus

This page is the syllabus for ECSE-4750 Computer Graphics Fall 2019.

This will be much the same as the old course site.

The requirements for ECSE 6964-01 are everything in 4750-01 plus an extra research paper.

1   Course content

1.1   Catalog description

ECSE-4750 and ECSE-6964-01 Computer Graphics

Introduction to Interactive Computer Graphics, with an emphasis on applications programming. Objects and viewers, and the synthetic camera model. Graphics architectures, the graphics pipeline, clipping, rasterization, and programmable shaders. Input and interaction. Geometric objects, homogeneous coordinates, and transformations. Viewing, hidden surface removal, frame and depth buffers, compositing, and anti-aliasing. Shading, light and materials, texture mapping, ray tracing, and radiosity. Intellectual property concerns. Extensive programming with the OpenGL API. Prerequisite: ECSE-2610 Computer Components & Operations, or CSCI-2500 Computer Organization, or equivalent. Fall term annually. 3 credit hours

CRN: 81149 and 84444.

1.2   Why take this course?

To understand and control the universe.

The massive data sets being produced by cheap sensors are useless unless they can be understood by people. Complicated machines are useless unless they can be easily controlled. This course will help you do both. The key is graphics and visualization. We don't just teach useful platform-independent tools. We also teach the underlying math and algorithms used by all tools so that you can design better tools.

1.3   How this course relates to other graphics courses at RPI

  1. My course gives you the math and programming skills to create the next generation replacements for the higher level tools that other courses use.
  2. OpenGL is the low-level assembly language of computer graphics. It gives you a more direct control of the HARDWARE. Higher level tools, like Blender, build on top of OpenGL. Higher level concepts, like ray tracing, are implemented in OpenGL.
  3. OpenGl is preferable to DirectX because OpenGl is open, vendor-neutral, and OS-neutral.
  4. The problem with very high level tools, like Blender, is that they restrict what you can do if what you want is outside the Blender model. You would use OpenGL to create Blender's replacement.
  5. Only OpenGl small enough to make available on smartphones.
  6. I will actually teach WebGL, a web-based version of OpenGL.

1.4   Overall Educational Objective

To provide students with a foundation in graphics applications programming.

1.5   Learning Outcomes

  1. to develop a facility with the relevant mathematics of computer graphics, e.g.,
    1. 3D rotations using both vector algebra and quaternions, and
    2. transformations and projections using homogeneous coordinations.
  2. to learn the principles and commonly used paradigms and techniques of computer graphics, such as
    1. the graphics pipeline,
    2. Splines and NURBS,
    3. ray tracing,
    4. visibility algorithms.
  3. to gain a proficiency with OpenGL, "a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics." - Wikipedia OpenGL is the most widely used platform-independent API, used on applications from games to virtual reality, implemented on platforms from mobile phones to supercomputers.

1.6   Why (Not) To Take This Course

Other courses might be a better fit if:

  1. You don't like programming.
  2. You don't like documenting your programs.
  3. You don't like math.
  4. You don't like reading.
  5. You don't like writing exams at the official scheduled times. The final exam may be as late as Dec 20.

OTOH, here are some reasons that you might prefer to take a course from me.

  1. I teach stuff that's fun and useful.
  2. I acknowledge that you are simultaneously taking several courses, and so try to make the workload fair. E.g., if you're taking 6 3-credit courses, then you should not be required to spend more than \(\frac{168}{6}\) hours per week per course :-).
  3. I try to base exam questions more on important topics that occupied a lot of class time, and which are described in writing, often on this wiki.
  4. I keep the course up-to-date and relevant.
  5. I welcome students from other RPI departments. According to SIS, this makes this course the largest 4000-level section in ECSE.

1.7   Prerequisites

  1. This is a senior CSYS course, and assumes a moderate computer maturity, represented in the catalog by either listed prereq. If you don't have either specific course, talk to me.
  2. You also must know some high level language, such as C++, sufficient to learn Javascript. One of many good online tutorials is W3Schools JavaScript Tutorial.
  3. Computer Graphics also assumes that you know, or be able to learn, some basic linear algebra, up to the level of what an eigenvalue is.
  4. If you're uncertain about taking this course, then, by all means, talk to me, or to previous people in it. If there is one specific fact that is unfamiliar, such as eigenvalue, then there's no problem at all.

2   Instructors

2.1   Professor

W. Randolph Franklin. BSc (Toronto), AM, PhD (Harvard)

Office:

Jonsson Engineering Center (JEC) 6026

Phone:

+1 (518) 276-6077 (forwards)

Email:

frankwr@YOUKNOWWHATGOESHERE.edu

Email is my preferred communication medium.

Sending from a non-RPI account is fine. However, please use an account that shows your name, at least in the comment field. A hashtag #CG is helpful.

Web:

https://wrf.ecse.rpi.edu/

Office hours:

After each lecture, usually as long as anyone wants to talk. Also by appointment.

Informal meetings:
 

If you would like to lunch with me, either individually or in a group, just mention it. We can then talk about most anything legal and ethical.

2.2   Teaching assistant

  1. Airas Akhtar

    Tues 11am, 1st floor of Folsom library near entrance. akhtaa2@ AT rpi DOT edu.

    For technical OpenGL questions, ask me after class.

  2. Come near the start of the time; if there is no one there she may leave.

  3. If you need more time, or a different time, then write, and she will try to accommodate you.

  4. Talk to me after class (or in class) about technical questions. Talk to xxx more about grading.

3   Course websites

3.1   Homepage

This current page https://wrf.ecse.rpi.edu/Teaching/graphics-f2019/ has lecture summaries, syllabus, homeworks, etc.

4   Reading material

4.1   Textbook

  1. Interactive Computer Graphics: A Top-Down Approach with WebGL, Seventh Edition, Edward Angel; Dave Shreiner.

    I picked this book because it covers WebGL, which is more portable, and because it has better supplementary material. Also, this book is widely used by other colleges.

  2. Textbook author's site, containing assorted stuff, like slides and code.

  3. I would have used the new e-text version (and listed it on RPI's textbook site for awhile), but was told on August 16 by Pearson that it's not available yet.

4.2   My notes on various graphics topics

These will supplement the text. I'll link them in to the lecture notes at the appropriate times.

4.3   Assorted online material

There is a lot of good, free, online material about OpenGL and graphics in general. I'll mention some of it; Google can find more.

5   Computer systems used

You will need the following computer systems; they could all be on one computer.

Public web server:
 

This course will use platform-independent OpenGL computer graphics written in Javascript and displayed with any major browser, including smart phones.

You will need to be able to create web pages with extensions .js and .html (or .htm) on some web server.

Web client:

You will need a web browser that can render and interact with WebGL pages. Most modern browsers, including smart phones, work.

You do not need a discrete graphics card.

To see if your computer is adequate, try this WebGL1 test or Angel's examples.

Misc other computing:
 

For some homeworks, you might need to run other computer programs. Generally I'll let you choose how to solve a given problem, i.e., what SW and OS to use.

I might use a little Mathematica.

6   LMS

RPI LMS will be used for you to submit homeworks and for us to distribute grades.

Some multiple-choice homeworks may be on LMS.

Announcements and the homeworks themselves will be available on this website.

7   Class times & places

  1. Mon & Thurs, 4:00-5:20pm, in Sage 4101 (lectures).
  2. Wed 6-7:30, in Sage 5101 (lab/recitation/lecture).

Wed will not always be used. Typical uses:

  1. To make up a missed class.
  2. For student presentations at the end.
  3. To review before a test.
  4. For TA meetings.

I intend no class activities outside the scheduled times, except for a final exam review, a day or two before the exam.

7.1   Lectures

You may miss classes. However

  1. You will miss iclicker points. However all the iclickers together are only 5%.
  2. You are also still responsible for knowing what happened.
  3. However, important announcements will be posted on the web.
  4. Except when some equipment fails, I post an copy of everything that I write in class.
  5. I may base exam questions on student questions in class.
  6. If you're scheduled to present something, say a term project summary, then you can't miss that.

You may use computers etc in class if you don't disturb others.

I welcome short questions, if the answers are also short.

8   Calendar

When What
Thu Aug 29 first class.
Mon Sep 2 no RPI classes
Tues Sep 3 Monday class
Wed Sep 4 class
Wed Sep 11 class
Wed Sep 18 class
Wed Sep 25 class
Mon Oct 14 no RPI classes
Wed Oct 16 no class
Thu Oct 17 midterm exam
Fri Oct 25 RPI drop date
Thurs Oct 31 due: term project title - team - 100 word summary
Mon Nov 5 no class
Thu Nov 8 no class
Nov 27-29 Thanksgiving
Mon Nov 11 brief progress report
Mon Nov 25 brief progress report
Mon Dec 2 due: term project videos to TA
Thu Dec 5 term project video show 1/2
Mon Dec 9 term project video show 2/2. Also the last class
Wed Dec 11 term project due
Dec 16-12/20 final exam sometime during these dates

Some of the other Wed lab sessions will be used for regular lectures.

Although it is unlikely, unforeseen events might force this calendar to be modified.

9   Assessment measures, i.e., grades

You are welcome to put copies of exams and homeworks in test banks, etc, if they are free to access. However I also put everything online for free.

9.1   Midterm exam

  1. There will be a midterm exam in class on Thurs Oct 17.

  2. If you have special needs, give me the memo by the week before, so that I can schedule someone to proctor you.

  3. The exam may contain some recycled homework questions.

  4. You may bring in one 2-sided 8.5"x11" paper with notes. You may not share the material with each other during the exam. No collaboration or communication (except with the staff) is allowed.

    (The exam can't be open book because some student share books and others use an online text.)

  5. As this chart shows, there is no correlation between the time taken to write the exam and the resulting grade.

    ../../images/ComputerGraphicsFall2007-midterm-grade-order.png

9.2   Homeworks

There will be a homework approximately every week. You are encouraged to do the homework in teams of 2, and submit one solution per team, on LMS, in any reasonable format. The other term member should submit only a note listing the team and saying who submitted the solution.

"Reasonable" means a format that the TAs and I can read. A scan of neat handwriting is acceptable. I might type material with a static CMS like nikola or blogging tool, sketch figures with xournal or draw them with inkscape, and do the math with mathjax. Your preferences are probably different.

9.3   Term project

  1. For the latter part of the course, most of your homework time will be spent on a term project.
  2. The project must be written in WebGL.
  3. It may use higher level packages on top of WebGL, provided that you are still programming.
  4. It must have programming; just selecting things from a menu and creating a nice scene is insufficient.
  5. It must be interactive and have 3D graphics.
  6. You will implement, demonstrate, and document something at least vaguely related to Computer Graphics. Here are some ideas:
    1. A tutorial program to demo some idea in this course, such as quaternions, which I might use in future years.
    2. A 3D game.
    3. A psychophysics experiment to test how well users can match colors.
    4. A physical simulation of 3 body orbits.
    5. A 3D fractal or julia set generator.
    6. An L-systems generator for random plants (as in botany).
    7. Something in stereo using Google Cardboard.
  7. You are encouraged do it in teams of up to 3 people. A team of 3 people would be expected to do twice as much work as 1 person.
  8. You may combine this with work for another course, provided that both courses know about this and agree. I always agree.
  9. You may build on existing work, either your own or others'. You have to say what's new, and have the right to use the other work. E.g., using any GPLed code or any code on my website is automatically allowable (because of my Creative Commons licence).
  10. You will produce a 3 minute video of your project to show in class, and then answer questions for one minute. You will send your video to the TA a few days in advance; she will show the video.
  11. You may demo it to Lingyu in one of the last few labs. A good demo will help; a bad demo hurt.
  12. Submit stuff on RPILMS as a tarball or zipfile containing any reasonable format of files or links to files. Each team should make only one substantive submission. The other term members should submit only a note listing the team and saying who made the real submission.
  13. For the video showing in class, there will be a signup sheet; sign up early to get your first choice.

9.3.1   Size of term project

  1. It's impossible to specify how many lines of code makes a good term project. E.g., I take pride in writing code that is can be simultaneously shorter, more robust, and faster than some others. See my 8-line program for testing whether a point is in a polygon: Pnpoly.
  2. According to Big Blues, when Bill Gates was collaborating with around 1980, he once rewrote a code fragment to be shorter. However, according to the IBM metric, number of lines of code produced, he had just caused that unit to officially do negative work.
  3. Some winners of The International Obfuscated C Code Contest (IOCCC) implement graphics projects in amazingly short programs. Note the beautiful formatting of many programs.
    1. 28 line ray-tracing program.
    2. 63 line interactive color auto racing program.
    3. 60 line interactive flight simulator.
    4. 8 line flying spheres program. However its graphics is pretty primitive.
    5. 73 line missile command game.
    6. 72 line Othello game, which beats me.
    7. 31 line 1st person maze walker, with perspective display.
    8. 115 line interactive fractal program, that puts up 2 X windows.
  4. Nevertheless, 10 pages of documentation and 1000 lines of code might be reasonable.

9.3.2   Deliverables

  1. An implementation showing
    1. interaction and
    2. 3D graphics.
  2. A video showing it running.
  3. A user guide showing how to use it.
  4. An implementation manual showing major design decisions.
  5. A class presentation of the video followed by 1 minute of questions.
Grading
Video  
project clearly described 10
good use of video or graphics 10
neat and professional 10
Project itself  
Graphics programming with good coding style 10
Use of interactivity or 3D 10
A nontrivial amount of it works (and that is shown) 10
Unusually creative 10
Writeup  
describes key design decisions 10
good examples 10
neat and professional 10
Total 100

A 10-minute demonstration to the TA is optional. If you do, she will give me a modifier of up to 10 points either way. I.e., a good demo will help, a bad one hurt.

9.4   Final exam

There will be a final exam on a date set by the Registrar. You may bring in two 2-sided 8.5"x11" sheets of paper with notes. You may not share bthe material with each other during the exam. No collaboration or communication (except with the staff) is allowed. The final exam will contain material from the whole course, but more from the last half. (new)

  1. Final exam F2014, Final exam F2014 solution,
  2. Final exam F2013, Final exam F2013 solution,
  3. Final exam F2012, Final exam F2012 solution,

The required final exam might be as late as Dec 21. Do not make travel plans that conflict with the exam. E.g., do not buy airplane tickets and then wait until the last minute to tell me.

9.5   ECSE 6964-01 Research paper

For ECSE 6964-01 students: In addition to everything else, a 5-page research paper, formatted as for an conference on a topic related to computer graphics. LaTeX is preferable as it is the standard for these conferences.

Note that 5 formatted pages contain more words than you might realize.

This will be weighted into the other components: this paper 1/3, everything else 2/3.

9.6   Iclickers

Iclicker questions will be posed in most classes. The questions are intended to be easy. Please bring your iclickers.

9.7   Correcting the Prof's errors

Occasionally I make mistakes, either in class or on the web site. The first person to correct each nontrival error will receive an extra point on his/her grade. One person may accumulate several such bonus points.

9.8   Extra bonuses

Constructive participation in class, and taking advantage of office hours may make a difference in marginal cases.

9.9   Weights and cutoffs

Relative weights of the different grade components
Component Weight
iClicker questions 5%
All the homeworks together 23%
Midterm exam 24%
Term project 24%
Final exam 24%

Even if the homeworks be out of different numbers of points, they will be normalized so that each homework has the same weight, except that the lowest homework will be dropped, as described below.

Grade cutoffs:
Percentage grade Letter grade
>=95.0% A
>=90.0% A-
>=85.0% B+
>=80.0% B
>=75.0% B-
>=70.0% C+
>=65.0% C
>=60.0% C-
>=55.0% D+
>=50.0% D
>=0% F

However, if that causes the class average to be lower than the prof and TA feel that the class deserves, based on how hard students appeared to work, then the criteria will be eased.

9.10   Missing or late work

  1. We will drop the lowest homework grade. That will handle excused absences, unexcused absences, dying relatives, illnesses, team trips, and other problems.
  2. Late homeworks will not be accepted.
  3. If you miss the midterm because of an excused absence, we will use your final exam grade also as your midterm grade.
  4. If you miss the final exam because of an excused absence, you may demonstrate your knowledge of the 2nd half of the course at an individual oral makeup exam.
  5. If your term project is late, you will be offered an incomplete and the project will be graded in Jan 2018.

9.11   Grade distribution & verification

  1. We'll post homework grading comments on LMS. We'll return graded midterm exams in class.
  2. If you disagree with a grade, then please
    1. report it within one week,
    2. in writing,
    3. emailed to the TA, with a copy to the prof.
  3. From time to time, we'll post your grades to LMS. Please report any missing grades within one week to the TA, with a copy to the prof.
  4. It is not allowed to wait until the end of the semester, and then go back 4 months to try to find extra points.
  5. We maintain standards (and the value of your diploma) by giving the grades that are earned, not the grades that are desired. Nevertheless, this course's average grade is competitive with other courses.
  6. Appeal first to the TA, then to the prof, to another prof acting as mediator if you wish, and then to the ECSE Head.
  7. Please state your objection in writing.

9.12   Mid-semester assessment

After the midterm, and before the drop date, we will compute an estimate of your performance to date.

9.13   Early warning system (EWS)

As required by the Provost, we may post notes about you to EWS, for example, if you're having trouble doing homeworks on time, or miss an exam. E.g., if you tell me that you had to miss a class because of family problems, then I may forward that information to the Dean of Students office.

10   Syllabus changes

Historically, this does not happen, but, unfortunately, circumstances might require that I change the syllabus during the semester.

11   Academic integrity

  1. See the Student Handbook for the general policy. The summary is that students and faculty have to trust each other. After you graduate, your most important possession will be your reputation.

Specifics for this course are as follows.

  1. You may collaborate on homeworks, but each team of 1 or 2 people must write up the solution separately (one writeup per team) using their own words. We willingly give hints to anyone who asks.
  2. The penalty for two teams handing in identical work is a zero for both.
  3. You may collaborate in teams of up to 3 people for the term project.
  4. You may get help from anyone for the term project. You may build on a previous project, either your own or someone else's. However you must describe and acknowledge any other work you use, and have the other person's permission, which may be implicit. E.g., my web site gives a blanket permission to use it for nonprofit research or teaching. You must add something creative to the previous work. You must write up the project on your own.
  5. Writing assistance from the Writing Center and similar sources in allowed, if you acknowledge it.
  6. The penalty for plagiarism is a zero grade.
  7. You must not communicate with other people or machines, exchange notes, or use electronic aids like computers and PDAs during exams.
  8. The penalty is a zero grade on the exam.
  9. Cheating will be reported to the Dean of Students Office.

13   Student feedback

Since it's my desire to give you the best possible course in a topic I enjoy teaching, I welcome feedback during (and after) the semester. You may tell me or write me or the TAs, or contact a third party, such as Prof Mike Wozny, the ECSE Dept head.

CG Class 23, Mon 2019-11-18

2   ACM SIGSPATIAL GIS Cup

I mentioned that 2 weeks ago I was at 27th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM SIGSPATIAL 2019).

They have an annual programming contest, the GISCup. My students and I won first place in 2018.

In 2016, we won 2nd place. We also won 2nd place in 2015, and 4th in 2014.

3   How I made a fast forward video in linux

For the 2019 International Geometry Summit Vancouver.

This is my FF video. It plays on some browsers, like chromium, but not on others, like firefox.

How I made it, approximately.

  1. This gives the same time to each slide.

  2. I made a pdf file of the slides, using LaTeX Beamer.

  3. Convert that to separate png files using Imagemagick:

    mogrify -verbose -density 500 -resize 1600x900\! -format png ./*.pdf

  4. Make a timed video of slides:

    ffmpeg -framerate 1:42 -pattern_type glob -i '*.png' -c:v libx264 video.mp4

  5. Note: Don't use Imagemagick convert, whose output runs slow.

  6. Write the transcript for my voiceover.

  7. Record my audio with my best headset.

  8. Combine audio and video:

    ffmpeg -i narration.wav -i video.mp4 combo.mp4

4   Week 13 slides

  1. 13_2 Polygon rendering. Includes clipping polygons, hidden surface algorithms.

    Start at slide 23.

  2. 13_3 Rasterization.

5   My commentaries

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

5.2   Polygon rendering

  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.

5.3   Visibility methods

Here's my summary of problems with the main 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 became 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.

CG Homework 5 solution

  1. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,0), (1,3,5)?

    a=(1,2,0). b=(1,3,5) a.b=7. |a|=sqrt(5). |b|=sqrt(35). cos t = 7/sqrt(5x35).

  2. (2 pts) (Reverse engineering rotations) In 2D, if the point (4,2) rotates about the origin to (2,-4), what's the angle?

    They're perpendicular. t=270 degrees.

  3. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}4\\2\\5\end{pmatrix} \times p\).

    Use https://wrf.ecse.rpi.edu/pmwiki/Research/Rotation3D

    \(M=\begin{pmatrix} 0 & -5 & 2\\ 5 & 0 & -4\\ -2 & 4 & 0 \end{pmatrix}\)

  4. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \left( \begin{pmatrix}2\\5\\4\end{pmatrix} \cdot p \right) \begin{pmatrix}2\\5\\4\end{pmatrix}\).

    \(M=\begin{pmatrix} 4 & 10 & 8\\10 & 25 & 20\\ 8&20&16 \end{pmatrix}\)

  5. (2 pts) Why can the following not possibly be a 3D Cartesian rotation matrix?

    \(\begin{pmatrix} 3& 0 &0\\1 & 0 &0\\0& 0 &1\end{pmatrix}\)

    1st column's length is not 1.

  6. (2 pts) Use any method (not involving soliciting answers on the internet) to rotate the point (6,6,9) by 120 degrees about the axis (2,2,3). Explain your method. (E.g., if you saw the answer in a vision, are your visions generally accurate?)

    Point is on axis and so doesn't move. (6,6,9).

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

    No because distances and angles don't change.

  8. (2 pts) What is the ''event loop''?

    Display controller (or whatever) waits, perhaps in a small loop, for an event, like mouse click. Then, if the user has registered a callback routine, controller calls it to handle the event. When the callback routine finishes, it returns to the controller to wait for the next event. This is a reasonable API when there are many events, and each one is triggered rarely.

  9. (2 pts) Why does putting all your vertices into an array and telling OpenGL about it make a big graphics program faster?

    The previous OpenGL version used a function call for each vertex, which sent each vertex's data to the GPU separately. That lot of calls took more time.

  10. (2 pts) Since the Z (aka depth) buffer looks so useful, why is it not enabled by default?

    1. It takes time and memory.
    2. This gives the user control over whether or not to use it.
  11. (2 pts) What's the quaternion representing a rotation of 180 degrees about the axis (1,0,0)?

    q=i.

  12. (2 pts) Use the quaternion formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

    q=i, p=j, p'=qpq* = i j (-i) = -j. new point = (0,-1,0).

  13. (2 pts) Use the vector formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

    p' = (0,1,0) (-1) + 0 (1,0,0) + (0,0,1) 0 = (0,-1,0)

    You could use intuition to see that the point is perpendicular to the axis and go from there.

  14. (14) Extend your program that displays the Starship Enterprise as follows:

    1. Do the rotation in the vertex shader instead of in the javascript program.
    2. Make the color of each pixel depend on its z-value.

    Whatever is handed in should indicate that the student has done this. TA does not need to run the program.

(Total: 40 points.)

CG Homework 9, due Mon 2019-11-25

  1. (10 pts) Look at Figures 6.37 and 6.38 on pages 310 and 311 of the textbook. Write 50-100 words on why they look different.
  2. (10 pts) Look at Figure 6.39 on page 314 of the textbook. What is it about the spheres that the global model looks different from the local?
  3. (10 pts) Consider the sphere \(x^2+y^2+z^2=169\). What is the normal to the sphere at the point (-12,3,-4)? Be sure your normal is normalized.
  4. (10 pts) Consider a block of glass with index of refraction 1.5. Some light is shining straight down on it. This is called normal incidence. How much of the light reflects off the glass and how much transmits into the glass? Hint: Use Fresnel's law.
  5. (10 pts) A small light source that is twice as far away is 1/4 as bright. That is, there is an inverse square fall off for brightness. However, when modeling light in graphics, we usually don't do that. Why?

(Total: 50 points.)

CG Homework 10, due Mon 2019-12-02

  1. (10 pts) Write a brief term project progress report.

  2. (40 pts) Send your term project video to the TA. This is a 3 minute video that will be shown to the class. It will demonstrate what your project can do. They will be shown on Dec 5 and 9, depending on how many there are.

    This is a model of a fast forward presentation that some conferences have. Each speaker gets 2 minutes to present a summary of his/her long presentation.

(Total: 50 points.)

CG Class 22, Thurs 2019-11-14

1   Week 12 slides ctd

  1. 12_3 Graphical Objects and Scene Graphs.

  2. 12_4 Graphical Objects and Scene Graphs 2.

  3. 12_5 Rendering overview.

    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.

2   Week 13 slides

  1. 13_1 Clipping.

    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 in class 13): 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'.

  2. 13_2 Polygon rendering. Includes clipping polygons, hidden surface algorithms.

    Up to slide 22.

3   Nice site on visualizing quaternions

Lessons by Grant Sanderson, Technology by Ben Eater.

here

CG Class 21, Mon 2019-11-11

CG Class 20, Thurs 2019-10-31

1   Week 10 slides

  1. 10_3 Compositing and Blending.

    Some of this material was removed from the current OpenGL, and some of the remaining stuff hasn't been included in WebGL (yet?). So, you have to learn just the high-level stuff, like what this is and why it's interesting.

    1. Compositing, using partial transparancy, creates complex scenes by blending simple components.
      1. It's hard to do accurately in the pipeline.
      2. Drawing objects back-to-front into the color buffer is a good heuristic.
      3. Clamping and accuracy are concerns.
    2. Fog effects provide a depth cue that helps the viewer understand the image.
    3. Anti-aliasing improves the image quality when there are small objects.
  2. 10_4 Imaging Applications.

    1. The GPU is so powerful that people figure ways to use it to do image processing things that it wasn't intended to.
    2. That started the field of GPGPU.
    3. Nvidia watched this happening and added new features to the GPU, like double-precision IEEE-standard floating point computations, to make this easier.
    4. The top line of Nvidia GPUs is designed for scientific computation and doesn't even have video outputs.
    5. The 2nd fastest known supercomputer has 15000 Nvidia GPUs.
  3. 10_5 Rendering the Mandelbrot Set.

    Show the power of GPU programming.

    The program is in Chapter 10.

2   Aliasing and anti-

  1. The underlying image intensity, as a function of x, is a signal, f(x).
  2. When the objects are small, say when they are far away, f(x) is changing fast.
  3. To display the image, the system evaluates f(x) at each pixel. That is, f(x) is sampled at x=0,1,2,3,...
  4. If f(x), when Fourier transformed, has frequencies higher than 1/2 (cycle per pixel), then that sampling is too coarse to capture the signal. See the Nyquist sampling theorem.
  5. When this hi-freq signal is sampled at too low a frequency, then the result computed for the frame buffer will have visual problems.
  6. It's not just that you won't see the hi frequencies. That's obvious.
  7. Worse, you will see fake low frequency signals that were never in the original scene. They are called '''aliases''' of the hi-freq signals.
  8. These artifacts may jump out at you, because of the Mach band effect.
  9. Aliasing can even cause (in NTSC) rapid intensity changes to cause fake colors and vv.
  10. Aliasing can occur with time signals, like a movie of a spoked wagon wheel.
  11. This is like a strobe effect.
  12. The solution is to filter out the hi frequencies before sampling, or sample with a convolution filter instead of sampling at a point. That's called '''anti-aliasing'''.
  13. OpenGl solutions:
    1. Mipmaps.
    2. Compute scene on a higher-resolution frame buffer and average down.
    3. Consider pixels to be squares not points. Compute the fraction of each pixel covered by each object, like a line. Lines have to have finite width.
  14. Refs:
    1. http://en.wikipedia.org/wiki/Aliasing
    2. http://en.wikipedia.org/wiki/Clear_Type
    3. http://en.wikipedia.org/wiki/Wagon-wheel_effect
    4. http://en.wikipedia.org/wiki/Spatial_anti-aliasing (The H Freeman referenced worked at RPI for 10 years).
    5. http://en.wikipedia.org/wiki/Mipmap
    6. http://en.wikipedia.org/wiki/Jaggies

3   Videos - military applications of graphics

US Military's Futuristic Augmented Reality Battlefield - Augmented Immersive Team Trainer (AITT)

Daqri's Smart Helmet Hands On

HoloLens Review: Microsoft's Version of Augmented Reality

US Military's Futuristic Augmented Reality Battlefield - Augmented Immersive Team Trainer (AITT)

'''Modeling and simulation''' is a standard term.

4   DARPA

  1. I've mentioned DARPA several times; they funded research into computer graphics starting in the 1970s. So here's some enrichment material on DARPA and autonomous vehicles. This shows why the US is the best in the world at R&D.

    Autonomous vehicles make a marvelous example of a successful engineering project. Many different parts all have to work to make the total project succeed. They include laser rangefinding, image recognition, a road database accurate to the specific lane, and GPS navigation. This is also a model for government - university - industry interaction.

    DARPA (The Defense Advanced Research Projects Agency) started this concept with a contest paying several $million in prizes. (DARPA started connecting computers in different cities with phone lines in 1968. This was the ARPAnet. They funded computer graphics in the 1970s and some early steps in virtual reality in the 1980s.)

    In the 1st contest, the best vehicle failed after about 10 miles. Five vehicles completed the 130 mile course in the 2nd contest. The winning project leader was Sebastian Thrun, a Stanford CS prof. He quit and moved to Google, who has now been funding this for several years.

    Finally, Dr Tony Tether, Director of DARPA when this happened, is an RPI BS EE grad. (He went to Stanford for his PhD).

5   Stereo viewing

  1. There are a number of techniques for stereo viewing of movies and videos, dating back to the 19th century.

    1. Make the left image red and the right one blue. Use red-blue glasses.

      This decreases the color experience, but the glasses are cheap.

    2. Polarize the left and right images differently. Movie theatres do this.

      The glasses are cheap. There is full color. The projection process is more complicated (= expensive).

    3. The glasses have shutters that block and clear the left and right eyes in turn. In sync, the TV or projector shows the left or right image.

      The projector is cheaper. The glasses are more expensive.

    4. Use a display with a parallax barrier.

      Only one person can view at a time. No glasses are needed.

    5. Use the fact that your eyes see bright objects faster than they see dim objects. The glasses have a simple grey filter over one eye. Beer companies have used this for commercials.

      No special display is needed. This works only with moving objects.

6   Updating web pages

  1. You may change a web page after it has been displayed. Editing elements and even adding or deleting them is allowed.
  2. One of the pick programs changes the displayed text in a div to show what you picked.
  3. Mathjax, the package I use to render LaTeX math in a web page, edits the displayed page to replace the math source with the rendered math.
  4. A standard way to make things appear and disappear is to include at the start all the elements that will be wanted later. Then make them visible or invisible. The tool on my homepage that makes sections expand and collapse does that.
  5. Every time something is changed on the page, the locations of everything on the page have to be recomputed. With a slow web browser, like old versions of IE, you can watch this.

8   Textbook programs

  1. Chapter 10 Mandlebrot showing serious computation in the fragment shader.

CG Homework 7, due Thurs 2019-11-07 2359

  1. (4 pts) Use the homogeneous matrix to project homogeneous points onto the plane 2x+3y+4z=5, with COP at the origin. What does the point (1,2,4,5) project to? Give the answer as a Cartesian point.

  2. (4 pts) Repeat the previous question with the COP changed to (1,1,1,1).

  3. (6 pts) Do exercise 5.6 on page 272 of the text,

  4. (6 pts) This question will take some thinking).

    Imagine that you have an infinitely large room illuminated by one infinitely long row of point lights. This figure shows a side view of the room.

    The lights are h above the floor and are 1 meter from each other. Assume that the ceiling above the lights is black and that no light reflects off of anything.

    An object at distance d from a light gets illuminated with a brightness \(\frac{1}{d^2}\).

    Each point on the floor is illuminated by all the lights, but more brightly by the closer lights.

    A point p directly below a light will be a little brighter than a point q halfway between two such points. That is the problem --- we want the floor (at least the part directly below the line of lights) to be evenly lit, at least within 1%.

    However, the higher the line of lights, the more evenly the floor will be lit.

    Your question is to tell us what is the minimum value for h so that the line of the floor below the line of lights is evenly lit within 10%.

    ../files/hw-lights.png

    E.g., the brightness at p is

    \(\sum_{i=-\infty}^{\infty} \;\; \frac{1}{\left(h^2+i^2\right)}\)

(Total: 20 points.)

CG Class 19, Mon 2019-10-28

1   No class next week

I'll be at https://sigspatial2019.sigspatial.org/ . Among other things, I'm part of a group producing a collection of Spatial Gems.

2   Why textures are hard to do

  1. ... although the idea is simple.
  2. You want to take each texel on each object, find which pixel it would draw on to, and draw it there.
  3. That's too expensive. Because of the projection, the projection of one texel is almost never the same size as a pixel.
    1. Sometimes several texels will project to the same pixel, so they have to be averaged together to get the pixel color.
    2. At other times, one texel will project over several pixels, so you want to blend pixel colors smoothly from one texel to the next texel.
    3. Most texels will be invisible in the final image. Even with today's computers, this wastes a lot of computing power.
  4. So, this is how it's really implemented.
    1. For each visible fragment, i.e., pixel, find which texel would draw there.
    2. This requires a backwards version of the graphics pipeline.
    3. The interesting surfaces are curved, where each parameter pair (u,v) uses a bicubic polynomial to generate an (x,y,z). You have to invert that.
    4. All this has to be computed at hundreds of millions of pixels per second.
    5. It usually utilizes special texture mapping hardware for speed.

4   Texture mapping programs

Programs.

  1. I'm not covering all the gruesome details of these programs, but just hitting highlights.

  2. particleDiffusion: buffer ping ponging of 50 particles initially placed randomly and then moving randomly with their previous positions diffused as a texture.

    It renders to a texture instead of to a color buffer. Then it uses the texture.

    There are better descriptions on the web. Search for 'webgl render texture'. I'll work with the textbook code. Jumping back and forth is confusing, partly because they might use different utility files.

    There are often better descriptions on the web than in the textbook. I've considered running a course only with web material. What do you think?

    https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API has good documentation.

  3. Several of the programs don't display on my laptop. They include bumpmap and render.

  4. Cubet: enabling and disabling the depth buffer and drawing translucent objects.

  5. pickcube etc. This prints the name of the name that you pick.

    1. This draws a label for each face into a separate buffer.
    2. Then it indexes into it with the coordinates of the mouse.

5   Week 10 slides

  1. 10_1 Reflection and Environment Maps.

  2. 10_2 Bump Maps.

    Perturb the surface normals to emulate small details (bumps).

CG Class 18, Thu 2019-10-24

1   My research

  1. RPI article about a completed project that I was part of:

    A Game-Changing Approach: Using the X-Box Kinect as a Sensor to Conduct Centrifuge Research. Team of Rensselaer Researchers Develop New Visualization Method to Evaluate Erosion Quantity and Pattern, November 8, 2016, by Jessica Otitigbe.

  2. Where I was last week:

    28th International Meshing Roundtable .

    I presented a paper Accelerating the exact evaluation of geometric predicates with GPUs, that was work by my Brazilian colleagues, Marcelo de Matos Menezes, Salles Viana Gomes Magalhães, Matheus Aguilar de Oliveira, and Rodrigo E. O. Bauer Chichorro at the Federal University of Vicosa.

    Talk slides.

    Paper.

  3. Much info is on my web site.

  4. Perhaps my most interesting problem is adapting my data structures and local geometry algorithms to GPUs, to intersect two 3D meshes.

2   Term project proposals

  1. See the syllabus.

  2. The proposal will be homework 6.

  3. Submit on LMS.

  4. If you want to remotely use a current GPU, parallel.ecse is available.

    It has a dual 14-core Xeon, 256GB DRAM, and Nvidia RTX 8000 and Pascal GeForce GTX 1080 GPUs.

3   Research paper for ECSE-6964

  1. If you are registered for the grad version of this class, then in addition to the term project, you must also write a research paper; see the syllabus.
  2. Simultaneously with the term project progress reports, please submit research paper progress reports.

4   Textures

Today's big new idea.

  1. Textures started as a way to paint images onto polygons to simulate surface details. They add per-pixel surface details without raising the geometric complexity of a scene.
  2. That morphed into a general array data format with fast I/O.
  3. If you read a texture with indices that are fractions, the hardware interpolates a value, using one of several algorithms. This is called sampling. E.g., reading T[1.1,2] returns something like .9*T[1,2]+.1*T[2,2].
  4. Textures involve many coordinate systems:
    1. (x,y,z,w) - world.
    2. (u,v) - parameters on one polygon
    3. (s,t) - location in a texture.
  5. Aliasing is also important.

Solution ECSE-4750 Computer Graphics CG class 16 and Midterm, RPI, Thurs 2019-10-17

Name, RCSID: WRF Solution

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 25 questions. Check that your copy of this test has all six 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) If you had 1,000,000 vertices and wanted to change all the vertex positions by multiplying each x-coordinate by the same vertex's y-coordinate, the fastest place to do it is:

    1. with a javascript function
    2. in the vertex shader
    3. in the fragment shader
    4. in the html file
    5. it can't be done.
  2. (2 pts) Color printing on a sheet of paper exemplifies

    1. additive color
    2. subtractive color
    3. multiplicative color
    4. divisive color
    5. exponential color
  3. (2 pts) Major components of the WebGl model as discussed in class are:

    1. Objects, viewer, light sources, planets, material attributes.
    2. Still cameras, video cameras, objects, light sources.
    3. Objects, viewer, light sources, material attributes.
    4. Colored objects, black and white objects, white lights, colored lights
    5. Flat objects, curved objects, near lights, distant lights.
  4. (2 pts) In the graphics pipeline, the step after rasterizing is the

    1. vertex shader
    2. primitive assembler
    3. fragment shader
    4. tesselation shader
    5. javascript callback
  5. (2 pts) Double buffering solves which problem:

    1. producing stereo images
    2. low memory bandwidth
    3. remote debugging PCs
    4. displaying from a frame buffer while it's being updated
    5. optimizing scheduling two elevators as a group
  6. (2 pts) What does this line do:

    gl.bindBuffer( gl.ARRAY_BUFFER, vBuffer );
    
    1. Create this buffer.
    2. Enable this buffer so that the shaders will use it.
    3. Get the address of variable vBuffer.
    4. Prevent this buffer from being modified.
    5. Specify that this buffer will be the object of future buffer operations.
  7. (2 pts) Which of these curved surface equation types makes it easy to generate points on the surface?

    1. explicit
    2. explicit and implicit
    3. explicit and parametric
    4. implicit
    5. parametric
  8. (2 pts) How do you draw a pentagon in WebGL?

    1. Split it into triangles.
    2. Split it into triangles if it is concave, otherwise draw it directly.
    3. Split it into triangles if it is convex, otherwise draw it directly.
    4. Draw it directly.
    5. Split it into hexagons.
  9. (2 pts) In the WebGL pipeline, the Primitive Assembler does what?

    1. fits together pieces of ancient Sumerian pottery.
    2. rotates vertices as their coordinate systems change.
    3. creates lines and polygons from vertices.
    4. finds the pixels for each polygon.
    5. reports whether the keyboard and mouse are plugged in correctly.
  10. (2 pts) If you do not tell WebGL to do hidden surface removal, and two objects overlap the same pixel, then what color is that pixel?

    1. WebGL 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
  11. (2 pts) This 3D homogeneous point: (4,3,2,1) corresponds to what Cartesian point:

    1. (4,3,2,1)
    2. (4,3,2)
    3. (3,2,1)
    4. (3/4, 1/2, 1/4)
    5. Some point at infinity.
  12. (2 pts) Consider an axis a=(0,1,0) and a point p=(2,3,4). What is the component of p that is perpendicular to a?

    1. (2,3,4)
    2. (2,0,4)
    3. (0,3,4)
    4. (0, 3/5, 4/5)
    5. (1,0,0)
  13. (2 pts) These next few questions are for 2D geometry. What is the 3x3 homogeneous matrix for the perspective projection whose center is at Cartesian (0,0) and whose viewplane is z=2?

    Cart: x' = 2x/z, z'=2. Hom: x'=2x, z=2z, w'=z.

    \(\begin{pmatrix} 2&0&0 \\ 0&2&0\\ 0&1&0 \end{pmatrix}\)

  14. (2 pts) What is the 3x3 homogeneous matrix for the parallel projection whose center is at Cartesian (0,0) and whose viewplane is z=2?

    Cart: x' = x, z'=2. Hom: x'=x, z=2w, w'=w.

    \(\begin{pmatrix} 1&0&0 \\ 0&0&2\\ 0&0&1 \end{pmatrix}\)

  15. (2 pts) When rotating an object, what can happen to an object?

    1. Straight lines might turn into curves.
    2. Straight lines stay straight, but angles might change.
    3. Straight lines stay straight, and angles don't change, but distances may change, either longer or shorter.
    4. Straight lines stay straight, and angles don't change, but distances might get longer.
    5. Straight lines stay straight, and angles and distances don't change.
  16. (2 pts) Translating the 2D homogeneous point by (2,3,4) by (in Cartesian terms) dx=1, dy=2 gives which new homogeneous point?

    1. (2,3,4)
    2. (1,2,3,4)
    3. (3,5)
    4. (6,11,4)
    5. (3,5,4)
  17. (2 pts) Rotating the 2D Cartesian point (0,-1) by \(90^o\) gives what:

    1. (1,0)
    2. (-1,0)
    3. (0,1)
    4. (0,-1)
    5. (-.7,.7)
  18. (2 pts) If a 3x3 rotation matrix has eigenvalues \(1, -\frac{1}{2}+\frac{\sqrt{3}}{2}i, -\frac{1}{2}-\frac{\sqrt{3}}{2}i\), then what is the rotation angle (in degrees)?

    Answer \(\cos\theta = -1/2\) so angle = 120 degrees.

  19. (2 pts) Give me a matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}2 \\ 1 \\ 0\end{pmatrix} \times p\).

    Answer \(\begin{pmatrix} 0&0&1 \\ 0&0&-2 \\ -1&2&0 \end{pmatrix}\)

  20. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,3), (2,4,6)?

    0

  21. (2 pts) This is a homogeneous 3D translation matrix: \(\begin{pmatrix} 3&0&0&2\\ 0&3&0&3\\ 0&0&3&4\\ 0&0&0&3 \end{pmatrix}\) Where is the Cartesian point (0,0,0) translated to? Give your result as a Cartesian point.

    One way is to divide the whole matrix by 3, which doesn't change its effect. Then you can read the translation off the right column: (2/3, 1, 4/3). So (0,0,0) translates to (2/3, 1, 4/3).

  22. (2 pts) What is the purpose of v1 in this line of code?

    var v2 = gl.getAttribLocation( program, "v1" );

    It's the name of an attribute variable in a shader.

  23. (2 pts) You're mixing 3 pure spectral colors: 20% of a color with wavelength 500nm, 40% of 600nm and 40% of 700nm. The result will appear to be one color. What diagram would you use to compute what color this mix would appear to be, to a normal person?

    CIE chromaticity diagram

  24. (2 pts) If i and j are quaternions, what is ij+ji?

    k-k = 0

  25. (2 pts) The quaternion k represents what rotation? Give the axis and angle.

    180 degrees (pi radians) about the z axis

End of midterm

CG Class 17, Mon 2019-21-10

2   Term projects

Start thinking. More later.

3   Lighting etc

  1. This Woman sees 100 times more colors than the average person.
  2. Phong lighting model: The total light at a pixel is the sum of
    1. Incoming ambient light times ambient reflectivity of the material at the pixel,
    2. Incoming diffuse light times diffuse reflectivity times a factor for the light source being low on the horizon,
    3. Incoming specular light times specular reflectivity times a factor for the eye not being aligned to the reflection vector, with an exponent for the material shininess,
    4. Light emitted by the material.
    5. That is not intended to be completely physical, but to give the programmer lots of parameters to tweak.
  3. In OpenGL you can do several possible levels of shading. Pick one of the following choices. Going down the list makes the shading better but costlier.
    1. Shade the whole polygon to be the color that you specified for one of the vertices.
    2. Bilinearly shade the polygon, triangle by triangle, from the colors you specified for its vertices.
    3. Use the Phong lighting model to compute the color of each vertex from that vertex's normal. Bilinearly interpolate that color over the polygon. That is called Gouraud shading.
    4. Bilinearly interpolate a surface normal at each pixel from normals that you specified at each vertex. Then normalize the length of each interpolated normal vector. Evaluate the Phong lighting model at each pixel from the interpolated normal. That is called Phong shading.
  4. Maureen Stone: Representing Colors as 3 Numbers (enrichment)
  5. Why do primary schools teach that the primary colors are Red Blue Yellow?

6   Chapter 6 programs

  1. Chapter 6

    1. wireSphere: wire frame of recursively generated sphere
    2. shadedCube: rotating cube with modified Phong shading
    3. shadedSphere1: shaded sphere using true normals and per vertex shading
    4. shadedSphere2: shaded sphere using true normals and per fragment shading
    5. shadedSphere3: shaded sphere using vertex normals and per vertex shading
    6. shadedSphere4: shaded sphere using vertex normals and per fragment shading
    7. shadedSphereEyeSpace and shadedSphereObjectSpace show how lighting computations can be carried out in these spaces
  2. Summary of the new part of shadedCube:

    1. var nBuffer = gl.createBuffer();

      Reserve a buffer id.

    2. gl.bindBuffer( gl.ARRAY_BUFFER, nBuffer );

      1. Create that buffer as a buffer of data items, one per vertex.
      2. Make it the current buffer for future buffer operations.
    3. gl.bufferData( gl.ARRAY_BUFFER, flatten(normalsArray), gl.STATIC_DRAW );

      Write a array of normals, flattened to remove metadata, into the current buffer.

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

      Get the address of the shader (GPU) variable named "vNormal".

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

      Declare that the current buffer contains 3 floats per vertex.

    6. gl.enableVertexAttribArray( vNormal );

      Enable the array for use.

    7. (in the shader) attribute vec3 vNormal;

      Declare the variable in the vertex shader that will receive each row of the javascript array as each vertex is processed.

    8. The whole process is repeated with the vertex positions.

      Note that the variable with vertex positions is not hardwired here. You pass in whatever data you want, and your shader program uses it as you want.

7   Computing surface normals

  1. For a curved surface, the normal vector at a point on the surface is the cross product of two tangent vectors at that point. They must not be parallel to each other.
  2. If it's a parametric surface, partial derivatives are tangent vectors.
  3. A mesh is a common way to approximate a complicated surface.
  4. For a mesh of flat (planar) pieces (facets):
    1. Find the normal to each facet.
    2. Average the normals of the facets around each vertex to get a normal vector at each vertex.
    3. Apply Phong (or Gouraud) shading from those vertex normals.

ECSE-4750 Computer Graphics CG class 16 and Midterm, RPI, Thurs 2019-10-17

Name, RCSID:

.

.

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 25 questions. Check that your copy of this test has all sevenxxxxxxxx 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) If you had 1,000,000 vertices and wanted to change all the vertex positions by multiplying each x-coordinate by the same vertex's y-coordinate, the fastest place to do it is:

    1. with a javascript function
    2. in the vertex shader
    3. in the fragment shader
    4. in the html file
    5. it can't be done.
  2. (2 pts) Color printing on a sheet of paper exemplifies

    1. additive color
    2. subtractive color
    3. multiplicative color
    4. divisive color
    5. exponential color
  3. (2 pts) Major components of the WebGl model as discussed in class are:

    1. Objects, viewer, light sources, planets, material attributes.
    2. Still cameras, video cameras, objects, light sources.
    3. Objects, viewer, light sources, material attributes.
    4. Colored objects, black and white objects, white lights, colored lights
    5. Flat objects, curved objects, near lights, distant lights.
  4. (2 pts) In the graphics pipeline, the step after rasterizing is the

    1. vertex shader
    2. primitive assembler
    3. fragment shader
    4. tesselation shader
    5. javascript callback
  5. (2 pts) Double buffering solves which problem:

    1. producing stereo images
    2. low memory bandwidth
    3. remote debugging PCs
    4. displaying from a frame buffer while it's being updated
    5. optimizing scheduling two elevators as a group
  6. (2 pts) What does this line do:

    gl.bindBuffer( gl.ARRAY_BUFFER, vBuffer );
    
    1. Create this buffer.
    2. Enable this buffer so that the shaders will use it.
    3. Get the address of variable vBuffer.
    4. Prevent this buffer from being modified.
    5. Specify that this buffer will be the object of future buffer operations.
  7. (2 pts) Which of these curved surface equation types makes it easy to generate points on the surface?

    1. explicit
    2. explicit and implicit
    3. explicit and parametric
    4. implicit
    5. parametric
  8. (2 pts) How do you draw a pentagon in WebGL?

    1. Split it into triangles.
    2. Split it into triangles if it is concave, otherwise draw it directly.
    3. Split it into triangles if it is convex, otherwise draw it directly.
    4. Draw it directly.
    5. Split it into hexagons.
  9. (2 pts) In the WebGL pipeline, the Primitive Assembler does what?

    1. fits together pieces of ancient Sumerian pottery.
    2. rotates vertices as their coordinate systems change.
    3. creates lines and polygons from vertices.
    4. finds the pixels for each polygon.
    5. reports whether the keyboard and mouse are plugged in correctly.
  10. (2 pts) If you do not tell WebGL to do hidden surface removal, and two objects overlap the same pixel, then what color is that pixel?

    1. WebGL 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
  11. (2 pts) This 3D homogeneous point: (4,3,2,1) corresponds to what Cartesian point:

    1. (4,3,2,1)
    2. (4,3,2)
    3. (3,2,1)
    4. (3/4, 1/2, 1/4)
    5. Some point at infinity.
  12. (2 pts) Consider an axis a=(0,1,0) and a point p=(2,3,4). What is the component of p that is perpendicular to a?

    1. (2,3,4)
    2. (2,0,4)
    3. (0,3,4)
    4. (0, 3/5, 4/5)
    5. (1,0,0)
  13. (2 pts) These next few questions are for 2D geometry. What is the 3x3 homogeneous matrix for the perspective projection whose center is at Cartesian (0,0) and whose viewplane is z=2?

    .
    
    
    
    
    
    
    .
    
  14. (2 pts) What is the 3x3 homogeneous matrix for the parallel projection whose center is at Cartesian (0,0) and whose viewplane is z=2?

    .
    
    
    
    
    
    
    .
    
  15. (2 pts) When rotating an object, what can happen to an object?

    1. Straight lines might turn into curves.
    2. Straight lines stay straight, but angles might change.
    3. Straight lines stay straight, and angles don't change, but distances may change, either longer or shorter.
    4. Straight lines stay straight, and angles don't change, but distances might get longer.
    5. Straight lines stay straight, and angles and distances don't change.
  16. (2 pts) Translating the 2D homogeneous point by (2,3,4) by (in Cartesian terms) dx=1, dy=2 gives which new homogeneous point?

    1. (2,3,4)
    2. (1,2,3,4)
    3. (3,5)
    4. (6,11,4)
    5. (3,5,4)
  17. (2 pts) Rotating the 2D Cartesian point (0,-1) by \(90^o\) gives what:

    1. (1,0)
    2. (-1,0)
    3. (0,1)
    4. (0,-1)
    5. (-.7,.7)
  18. (2 pts) If a 3x3 rotation matrix has eigenvalues \(1, -\frac{1}{2}+\frac{\sqrt{3}}{2}i, -\frac{1}{2}-\frac{\sqrt{3}}{2}i\), then what is the rotation angle (in degrees)?

    .
    
    
    
    
    
    
    .
    
  19. (2 pts) Give me a matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}2 \\ 1 \\ 0\end{pmatrix} \times p\).

    .
    
    
    
    
    
    
    .
    
  20. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,3), (2,4,6)?

    .
    
    
    
    
    
    
    .
    
  21. (2 pts) This is a homogeneous 3D translation matrix: \(\begin{pmatrix} 3&0&0&2\\ 0&3&0&3\\ 0&0&3&4\\ 0&0&0&3 \end{pmatrix}\) Where is the Cartesian point (0,0,0) translated to? Give your result as a Cartesian point.

    .
    
    
    
    
    
    
    .
    
  22. (2 pts) What is the purpose of v1 in this line of code?

    var v2 = gl.getAttribLocation( program, "v1" );

    .
    
    
    
    
    
    
    
    
    .
    
  23. (2 pts) You're mixing 3 pure spectral colors: 20% of a color with wavelength 500nm, 40% of 600nm and 40% of 700nm. The result will appear to be one color. What diagram would you use to compute what color this mix would appear to be, to a normal person?

    .
    
    
    
    
    .
    
  24. (2 pts) If i and j are quaternions, what is ij+ji?

    .
    
    
    
    
    .
    
  25. (2 pts) The quaternion k represents what rotation? Give the axis and angle.

    .
    
    
    
    
    .
    

End of midterm

CG Class 15, Thu 2019-10-10

1   Midterm exam

  1. In 7 days, Thurs Oct 17, in class.

  2. You may bring in one 2-sided 8.5"x11" paper with notes. You may not share the material with each other during the exam. No collaboration or communication (except with the staff) is allowed.

    (The exam can't be open book because some student share books and others use an online text.)

  3. Last year's midterm exam.

  4. Its solution.

  5. The exam may contain some recycled homework questions.

  6. Here are several older exams, with some solutions. This year's topics will be slightly different, but will be largely the same. OTOH, since there are a finite number of electrons in the universe and they say that recycling is good, I'll recycle many of these questions.

    1. Midterm F2017.
    2. Midterm F2017 solution.
    3. Midterm F2016.
    4. Midterm F2014, Midterm F2014 Solution
    5. Midterm F2013, Midterm F2013 Solution
    6. Midterm F2012, Midterm F2012 Solution

If you prepared answers to all the questions on all the old tests, then you'd do well this semester, except for the new stuff. However, you would also deserve to do well since you'd know the material.

  1. Part of today will be a review of previous lectures and exams.
  2. I'll discuss other answers in the review, or you may figure out answers on your own.

2   No homework out today

However there may be a homework assigned next week due the week after.

3   Possible spring courses

  1. ECSE-4740 Applied Parallel Computing for Engineers. Its instructor is excellent. There is also a 6000-level version.
  2. An independent Computer Graphics reading course directed by me.

CG Class 14, Mon 2019-10-07

1   Iclicker questions

  1. About the next few questions:

    1. The next few questions will work with 3D points like \(p=\begin{pmatrix}1\\2\\3\end{pmatrix}\).
    2. I'll also use matrices like \(M=\begin{pmatrix}2&0&0\\0&2&0\\0&0&2\end{pmatrix}\).
    3. We can transform points thus: \(q=Mp\). This gives \(q=\begin{pmatrix}2\\4\\6\end{pmatrix}\).
    4. Common types of transformations are rotation, translation, scaling, and perspective or projection.
    5. I haven't yet discussed the following topics. This is to see what you already know. I'll let you correct your answers.

    The above matrix is what type of transformation:

    1. identity
    2. perspective
    3. rotation
    4. scaling
    5. translation
  2. \(M=\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}\) is what type of transformation?

    1. identity
    2. perspective
    3. rotation
    4. scaling
    5. translation
  3. \(M=\begin{pmatrix}.6&.8&0\\-.8&.6&0\\0&0&1\end{pmatrix}\) is what type of transformation?

    1. identity
    2. perspective
    3. rotation
    4. scaling
    5. translation

2   Midterm exam

  1. In 10 days, Thurs Oct 17, in class.

  2. You may bring in one 2-sided 8.5"x11" paper with notes. You may not share the material with each other during the exam. No collaboration or communication (except with the staff) is allowed.

    (The exam can't be open book because some student share books and others use an online text.)

  3. Last year's midterm exam.

  4. Its solution.

  5. The exam may contain some recycled homework questions.

  6. Here are several older exams, with some solutions. This year's topics will be slightly different, but will be largely the same. OTOH, since there are a finite number of electrons in the universe and they say that recycling is good, I'll recycle many of these questions.

    1. Midterm F2017.
    2. Midterm F2017 solution.
    3. Midterm F2016.
    4. Midterm F2014, Midterm F2014 Solution
    5. Midterm F2013, Midterm F2013 Solution
    6. Midterm F2012, Midterm F2012 Solution

If you prepared answers to all the questions on all the old tests, then you'd do well this semester, except for the new stuff. However, you would also deserve to do well since you'd know the material.

  1. Part of this Thurs will be a review of previous lectures and exams.
  2. I'll discuss other answers in the review, or you may figure out answers on your own.

3   Comments on recent powerpoint slides

  1. I didn't show WebGL Transformations Angel_UNM_14_5_4.ppt in detail since it is mostly obsolete.
    1. The old OpenGL modelview and projection matrix idea is now deprecated, but is interesting for its subdivision of transformations into two functions.
    2. The modelview matrix moves the world so that the camera is where you want it, relative to the objects. Unless you did a scale, the transformation is rigid - it preserves distances (and therefore also angles).
    3. The projection matrix view-normalizes the world to effect your desired projection and clipping. For a perspective projection, it does not preserve distances or angles, but does preserve straight lines.

4   Angel programs - Chapter 5

Chapter 5

  1. hata shows:
    1. Using a modelview matrix set by lookat and a projection matrix set by ortho
    2. Drawing a mesh with line strips.
  2. hat shows:
    1. Drawing the same points both as a triangle fan and as a line loop.
    2. Setting options to make the lines slightly in front of the triangles.
    3. Doc for depthfunc.
    4. Doc for polygonoffset.
  3. ortho1 and ortho2 show clipping with an interactive orthographic (parallel) projection.
  4. perspective1 and 2 show an interactive perspective projection.
  5. shadow shows a shadow.
  6. Notes about the computer programs:
    1. The point is not to teach javascript; it's just the vehicle. Before javascript, I taught C++. Javascript is easier.
    2. One point is to teach a widely used API, i.e., WebGL.
    3. Another point is to teach graphics concepts like projection and viewing, and their APIs, like lookAt.
    4. These concepts will exist in any graphics API.

5   Section 7 slides

  1. 7_1 Orthogonal projection matrices.

    Big idea: 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'. See slide 14.

  2. 7_2 Perspective projection matrices and the normalization transformation.

    Big idea: We can do the same with perspective projections. The objects are distorted like in a fun house. See slide 8.

6   Section 7 slides ctd

  1. 7_3 Meshes.

    Big ideas:

    1. Meshes are common for representing complicated shapes.
    2. We can plot a 2 1/2 D mesh back to front w/o needing a depth buffer.
    3. Unstructured point clouds with millions of points from laser scanners are common. We can turn them into a mesh by using various heuristics about the expected object.
    4. Drawing the mesh edges a little closer than the faces is a hack that probably works most of the time if the scene isn't too complex. I.e., go ahead and use it, but don't be surprised.
  2. 7_4 Shadows.

    Big idea:

    1. If there is one light source, we can compute visibility with it as the viewer.
    2. Somehow mark the visible (i.e., lit) and hidden (i.e., shadowed) portions of the objects.
    3. Then recompute visibility from the real viewer and shade the visible objects depending on whether they are lit or shadowed.
    4. This works for a small number of lights.
    5. This capability is in OpenGL but not in WebGL, so this topic is enrichment only (= will not be examined).
  3. 7_5 Lighting and shading I.

Big big topic.

7   RPI's long history in Computer Graphics

  1. Curtis Priem.
  2. Mike Wozny, Head of ECSE, was one of the founders of IEEE Computer Graphics and Applications, which printed that article by Maureen Stone.
  3. William Lorensen, co-inventor of marching cubes, earned his BS and MS here at RPI.

CG Class 13, Thur 2019-10-03

1   Iclicker registration problems

The majority of students in this class have not registered their iclickers. The following iclickers have been used in class but not registered to a student in this class. Airas may be contacting people to see what went wrong. I've also emailed the unregistered students. You need to fix this to get your iclicker grade. Thanks.

#36D7EF0E #39AA7DEE #3AFD11D6 #3BE6815C #42A38061 #42ABA841 #42AF28C5 #42B522D5 #42CA42CA #42F42690 #434B0800 #434C6768 #4360B794 #43CA7AF3 #44360C7E #443EEE94 #443F89F2 #45C6CE4D #45CC66EF #45CECB40 #46C70C8D #46E54DEE #47D621B0 #4A05C788 #4A26C3AF #4A8CA066 #4B3AC9B8 #E6274B8A

2   Iclicker questions

  1. Let a=(1,0,0) and p=(2,3,4). Then the component of p that is perpendicular to a is
    1. (0,3,4)
    2. (0,3/2,2)
    3. (1,0,0)
    4. (2,0,0)
    5. (2,3,4)
  2. I want a matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}-1&0&1\end{pmatrix} \times p\). M =
    1. \(\begin{pmatrix} 0&-1&0\\1&0&1\\0&-1&0 \end{pmatrix}\)
    2. \(\begin{pmatrix} 0&1&0\\-1&0&-1\\0&1&0 \end{pmatrix}\)
    3. \(\begin{pmatrix} 0&1&0\\1&0&1\\0&1&0 \end{pmatrix}\)
    4. \(\begin{pmatrix} 1&0&-1\\0&0&0\\-1&0&1 \end{pmatrix}\)
    5. \(\begin{pmatrix} 1&0&-1\\1&0&-1\\1&0&-1 \end{pmatrix}\)
  3. What is the angle (in degrees) between these two vectors: (1,0,0), (1,2,3)?
    1. \(1/\sqrt{13}\).
    2. \(1/\sqrt{14}\).
    3. \(\arccos(1/\sqrt{13})\).
    4. \(\arccos(1/\sqrt{14})\).
  4. This is a homogeneous 3D translation matrix: \(\begin{pmatrix} 2&0&0&2\\ 0&2&0&3\\ 0&0&2&4\\ 0&0&0&2 \end{pmatrix}\) Where is the Cartesian point (0,0,0) translated to?
    1. (0,0,0)
    2. (1,3/2,2)
    3. (1,3/2,2,1)
    4. (2,3,4)
    5. (2,3,4,2)
  5. Rotating the 2D Cartesian point (-1,0) by \(90^o\) gives what:
    1. (1,0)
    2. (-1,0)
    3. (0,1)
    4. (0,-1)
    5. (-.7,.7)
  6. When using the vector rule to rotate a point p about an axis by an angle:
    1. Neither the point nor the axis need to be of any particular length.
    2. The point must be at a distance one from the origin.
    3. The axis must be of unit length.
    4. Both B and C.
    5. The point's distance from the origin must equal the axis's length.
  7. Multiplying a complex number x+iy by e^(i pi/4) is equivalent to doing what to the point (x,y):
    1. Rotating it by 90 degrees.
    2. Rotating it by 90 radians.
    3. Rotating it by 45 degrees.
    4. Translating it by 90 degrees.
    5. Nothing; this doesn't change the point.
  8. If i and j are quaternions, what is i+j?
    1. -k.
    2. 0.
    3. 1.
    4. i+j, there is no simpler representation.
    5. k.
  9. If i and j are quaternions, what is ij?
    1. -k.
    2. 0.
    3. 1.
    4. i+j, there is no simpler representation.
    5. k.
  10. The quaternion i represents what rotation?
    1. 180 degrees about the x-axis.
    2. 90 degrees about the x-axis.
    3. 180 degrees about the y-axis.
    4. 90 degrees about the y-axis.
    5. no change, i.e., 0 degrees about anything.
  11. Which rotation methodology is best when working with nested gimbals?
    1. vectors
    2. quaternions
    3. matrices
    4. Euler angles
    5. None are particularly good.
  12. Which make it easy to combine two rotations into one?
    1. vectors
    2. quaternions
    3. matrices
    4. Euler angles
    5. B and C

3   Shadertoy

Shadertoy.com is a very nice use of WebGL. The co-creator of the website has an account named "iq", searching for that account brings up some renders that really push Webgl to its limits in really pretty ways (he used to work for Pixar and Siggraph) - Seretsi Khabane Lekena '17.

You need a machine with reasonable graphics to show these. The TP Yoga that I bring to class is not one of them.

4   Section 6 slides

(The slides are organized into week that don't correspond to textbook chapters.)

#.`6_1 Building Models <https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/PPT/WEEK06/Angel_UNM_14_6_1.ppt>`_.

Big idea: separate the geometry from the topology.

#.`The Rotating Square <https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/PPT/WEEK06/Angel_UNM_14_6_2.ppt>`_.

Big idea: render by elements.

#.`6_3 Classical Viewing <https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/PPT/WEEK06/Angel_UNM_14_6_3.ppt>`_.

Big ideas: parallel (orthographic) and perspective projections. The fine distinctions between subclasses of projections are IMO obsolete.
  1. 6_4 Computer Viewing: Positioning the Camera.

  2. 6_5 Computer Viewing: Projection.

    Big idea: view normalization. We'll see this more in chapter 7.

CG Homework 5, due Thu 2019-10-10 2359

  1. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,0), (1,3,5)?

  2. (2 pts) (Reverse engineering rotations) In 2D, if the point (4,2) rotates about the origin to (2,-4), what's the angle?

  3. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}4\\2\\5\end{pmatrix} \times p\).

  4. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \left( \begin{pmatrix}2\\5\\4\end{pmatrix} \cdot p \right) \begin{pmatrix}2\\5\\4\end{pmatrix}\).

  5. (2 pts) Why can the following not possibly be a 3D Cartesian rotation matrix?

    \(\begin{pmatrix} 3& 0 &0\\1 & 0 &0\\0& 0 &1\end{pmatrix}\)

  6. (2 pts) Use any method (not involving soliciting answers on the internet) to rotate the point (6,6,9) by 120 degrees about the axis (2,2,3). Explain your method. (E.g., if you saw the answer in a vision, are your visions generally accurate?)

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

  8. (2 pts) What is the ''event loop''?

  9. (2 pts) Why does putting all your vertices into an array and telling OpenGL about it make a big graphics program faster?

  10. (2 pts) Since the Z (aka depth) buffer looks so useful, why is it not enabled by default?

  11. (2 pts) What's the quaternion representing a rotation of 180 degrees about the axis (1,0,0)?

  12. (2 pts) Use the quaternion formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

  13. (2 pts) Use the vector formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

  14. (14) Extend your program that displays the Starship Enterprise as follows:

    1. Do the rotation in the vertex shader instead of in the javascript program.
    2. Make the color of each pixel depend on its z-value.

(Total: 40 points.)

CG Class 12, Mon 2019-09-30

1   Homework 3 extended

Because of Thursday's blackout, you may upload homework 3 through tonight.

2   Iclicker questions

  1. How are you using the textbook?
    1. I bought a physical copy.
    2. I rented a physical copy.
    3. I'm sharing a physical copy with one or more friends.
    4. I obtained a PDF.
    5. I don't have access since I never plan to read it.
  2. Consider a pinhole camera as discussed in slide 12 of ppt presentation 1_5. Let d=2. To where does the point (1,3,-2) project? Use the equation on that slide. x/z/d should be parenthesized as x/(z/d).
    1. (-1,-3,-2)
    2. (1,3,-2)
    3. (1,3,2)
    4. (1/2, 3/2, 1)
    5. (1/2, 3/2, -1)
  3. Look at this CIE chromaticity diagram. If you wanted to make white by mixing one spectrally pure color with the pure color with wavelength 600 nm, what wavelength would that other color be?
    1. 400
    2. 485
    3. 535
    4. 580
    5. It's not possible, because purple is not a spectrally pure color. http://upload.wikimedia.org/wikipedia/commons/3/3b/CIE1931xy_blank.svg
  4. When rotating an object, what can happen to an object?
    1. Straight lines might turn into curves.
    2. Straight lines stay straight, but angles might change.
    3. Straight lines stay straight, and angles don't change, but distances may change, either longer or shorter.
    4. Straight lines stay straight, and angles don't change, but distances might get longer.
    5. Straight lines stay straight, and angles and distances don't change.
  5. The parametric equation of a line through the points (1,1) and (2,3) is:
    1. P = (1,1) + t(1,0) + u(0,1)
    2. P = (1,1) + t(1,1)
    3. P = (1,1) + t(1,2)
    4. P = (1,1) + t(2,3)
    5. P = t(1,1) + u(2,3)
  6. The normal vector to the plane through the points (1,0,0), (0,1,0), (0,0,1) is
    1. (1,0,0)
    2. \(\left( 1/\sqrt{3}, 1/\sqrt{3}, 1/\sqrt{3} \right)\)
    3. (-1, 0, 0)
    4. 3
    5. (1/3, 1/3, 1/3)
  7. Translating the 2D homogeneous point by (1,2,3) by (in Cartesian terms) dx=1, dy=2 gives which new homogeneous point?
    1. (1,2,3)
    2. (1,2,3,4)
    3. (2,4)
    4. (2,4,3)
    5. (4,8,3)
  8. Rotating the 2D Cartesian point (0,1) by {$90^o$} gives what:
    1. (1,0)
    2. (-1,0)
    3. (0,1)
    4. (0,-1)
    5. (-.7,.7)
  9. If a 3x3 rotation matrix has eigenvalues \(1, -\frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2}i, -\frac{\sqrt{2}}{2}-\frac{\sqrt{2}}{2}i\), then what is the rotation angle (in degrees)?
    1. 0
    2. 45
    3. 90
    4. 135
    5. 180

3   Euler angles and Gimbal lock

  1. http://www.youtube.com/watch?v=rrUCBOlJdt4&feature=related Gimble Lock - Explained.

    One problem with Euler angles is that multiple sets of Euler angles can degenerate to the same orientation. Conversely, making a small rotation from certain sets of Euler angles can require a jump in those angles. This is not just a math phenomenon; real gyroscopes experience it.

  2. http://en.wikipedia.org/wiki/Gimbal_lock

  3. What is Gimbal Lock and why does it occur? - an animator's view.

4   Quaternions

  1. Finish off 3D rotations by learning quaternions.
  2. It's easy to find the quaternion rotation for a given axis and angle.
  3. and vice versa.
  4. Combining two rotations and finding the axis and angle of the equivalent single rotation is easy.

5   3D interpolation

  1. My note on 3D Interpolation, which is better than the textbook section on animating with Euler angles.
  2. The problem with stepping the 3 Euler angles together is that the combo rotation might not be smooth.

CG Class 11, Thu 2019-09-26

1   Iclicker questions

  1. This 3D homogeneous point: (4,3,2,1) corresponds to what Cartesian point:
    1. (4,3,2,1)
    2. (4,3,2)
    3. (3,2,1)
    4. (3/4, 1/2, 1/4)
    5. Some point at infinity.
  2. This question is about 2D geometry. The matrix for a translation by 2 in x and 3 in y is what?
    1. \(\begin{pmatrix} 2&0&1\\0&3&1\\0&0&1\end{pmatrix}\) B. \(\begin{pmatrix} 2&0&0\\0&3&0\\0&0&1\end{pmatrix}\) C. \(\begin{pmatrix} 1&0&0\\0&1&0\\2&3&1\end{pmatrix}\) D. \(\begin{pmatrix} 1&0&2\\0&1&3\\0&0&1\end{pmatrix}\) E. \(\begin{pmatrix} 1&0&2\\0&1&3\\0&0&0\end{pmatrix}\)
  3. Consider an axis a=(1,0,0) and a point p=(2,3,4). What is the component of p that is perpendicular to a?
    1. (2,3,4)
    2. (2,0,0)
    3. (0,3,4)
    4. (0, 3/5, 4/5)
    5. (1,0,0)
  4. Consider an axis a=(1,0,0) and a point p=(2,3,4). What is the component of p that is parallel to a?
    1. (2,3,4)
    2. (2,0,0)
    3. (0,3,4)
    4. (0, 3/5, 4/5)
    5. (1,0,0)
  5. These next few questions are for 2D geometry. What is the homogeneous matrix for the perspective projection whose center is at Cartesian (0,0) and whose viewplane is x=1?
    1. \(\begin{pmatrix} 1&0&0\\0&1&0\\1&0&0\end{pmatrix}\)
    2. \(\begin{pmatrix} 1&0&0\\0&1&0\\0&2&0\end{pmatrix}\)
    3. \(\begin{pmatrix} 1&0&0\\0&0&2\\0&0&1\end{pmatrix}\)
  6. What is the homogeneous matrix for the perspective projection whose center is at Cartesian (0,0) and whose viewplane is y=1/2?
    1. \(\begin{pmatrix} 1&0&0\\0&1&0\\1&0&0\end{pmatrix}\)
    2. \(\begin{pmatrix} 1&0&0\\0&1&0\\0&2&0\end{pmatrix}\)
    3. \(\begin{pmatrix} 1&0&0\\0&0&2\\0&0&1\end{pmatrix}\)
  7. What is the homogeneous matrix for the parallel projection whose center is at Cartesian (0,0) and whose viewplane is y=2?
    1. \(\begin{pmatrix} 1&0&0\\0&1&0\\1&0&0\end{pmatrix}\)
    2. \(\begin{pmatrix} 1&0&0\\0&1&0\\0&2&0\end{pmatrix}\)
    3. \(\begin{pmatrix} 1&0&0\\0&0&2\\0&0&1\end{pmatrix}\)

2   Textbook slides: Chapter 5 ctd

  1. 5_2 Homogeneous coordinates
  2. 5_3 Transformations.
  3. 5_4 WebGL transformations
  4. 5_5 Applying transfomations
  5. WebGL Transformations Angel_UNM_14_5_4.ppt since it is mostly obsolete.
    1. The old OpenGL modelview and projection matrix idea is now deprecated, but is interesting for its subdivision of transformations into two functions.
    2. The modelview matrix moves the world so that the camera is where you want it, relative to the objects. Unless you did a scale, the transformation is rigid - it preserves distances (and therefore also angles).
    3. The projection matrix view-normalizes the world to effect your desired projection and clipping. For a perspective projection, it does not preserve distances or angles, but does preserve straight lines.

3   3D rotation ctd

  1. Continue my note on 3D rotation. including 4D rotations and Euler angles.

CG Homework 4, due Thu 2019-10-03 2359

Homework 4, due Thu 2019-10-03 2359

Modify the triangle or cad program as follows:

  1. The user can draw triangles by clicking on 3 vertices. Don't use fans or strips, just simple triangles.
  2. Have 3 sliders to set the depths of the 3 vertices. Thus the triangles can be slanted in distance.
  3. Have 3 menus to set the colors of the 3 vertices. Interpolate the colors inside the triangles.
  4. Give each triangle a random velocity and angular momentum.
  5. If a triangle hits the border, have it bounce off.
  6. Now have fun creating a demo scene where the triangles move and cut through each other.

(Total: 50 points.)

CG Class 10, Mon 2019-09-23

1   Today's iclicker questions

  1. Bump mapping is
    1. more realistic than actually 3D modeling each bump
    2. faster than actually 3D modeling each bump
    3. both
    4. neither
    5. unrelated to modeling bumps; the name is coincidental.
  2. How do you draw a pentagon in WebGL?
    1. Split it into triangles.
    2. Split it into triangles if it is concave, otherwise draw it directly.
    3. Split it into triangles if it is convex, otherwise draw it directly.
    4. Draw it directly.
    5. Split it into hexagons.
  3. How do you draw a pentagon in WebGL?
    1. Split it into triangles.
    2. Split it into triangles if it is concave, otherwise draw it directly.
    3. Split it into triangles if it is convex, otherwise draw it directly.
    4. Draw it directly.
    5. Split it into hexagons.
  4. In the WebGL pipeline, the Primitive Assembler does what?
    1. fits together pieces of ancient Sumerian pottery.
    2. rotates vertices as their coordinate systems change.
    3. creates lines and polygons from vertices.
    4. finds the pixels for each polygon.
    5. reports whether the keyboard and mouse are plugged in correctly.
  5. To draw into only part of the graphics window you would call:
    1. gl.drawpart
    2. gl_Position
    3. gl.viewport
    4. gl.window
    5. There's no builtin routine; you have to scale your graphics yourself to achieve this.
  6. What buffer is used by WebGl to do hidden surface removal?
  1. Closest object buffer
  2. Color buffer
  3. Depth or Z buffer
  4. Hidden-surface buffer
  5. Ray-trace buffer
  1. If you do not tell WebGL to do hidden surface removal, and two objects overlap the same pixel, then what color is that pixel?
    1. WebGL 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
  2. gasket2 has this code: var points=[ ]; ... points.push(a,b,c); What does push do here?
    1. Appends new entries to the end of points.
    2. Inserts new entries at the start of points.
    3. Overwrites the first entries of points.
    4. Overwrites the last entries of points.
    5. Throws an error because we didn't specify a size for points.
  3. Why would you want to send a variable to a vertex shader that has the same value for every vertex?
    1. the vertex's coordinates
    2. the vertex's color
    3. the object's global orientation
    4. the location of the global light source
    5. C and D.
  4. How would you send that variable to the vertex shader?
    1. as a varying variable.
    2. as a uniform variable.
    3. in another array similar to the vertex array.
    4. with a bindBuffer call.
    5. with a bufferData call.
  5. You call gl.BufferSubData to do what?
    1. to add or replace part of the buffer in the GPU.
    2. to define a submarine object.
    3. to subtract some data in the buffer.
    4. to tell the GPU to look for a pattern and substitute any occurrences,
    5. to tell the GPU to use a subroutine instead of the main program.

4   3D rotation

IMNSHO I do this topic better than the textbook.

My note on 3D rotation.

CG Class 9, Thurs 2019-09-19

1   Today's iclicker questions

  1. What does this line do:

    gl.bindBuffer( gl.ARRAY_BUFFER, vBuffer );
    
    1. Create this buffer.
    2. Enable this buffer so that the shaders will use it.
    3. Get the address of variable vBuffer.
    4. Prevent this buffer from being modified.
    5. Specify that this buffer will be the object of future buffer operations.
  2. What does this line do:

    var vBuffer = gl.createBuffer();
    
    1. Create this buffer.
    2. Enable this buffer so that the shaders will use it.
    3. Get the address of variable vBuffer.
    4. Prevent this buffer from being modified.
    5. Specify that this buffer will be the object of future buffer operations.
  3. How does gl.drawArrays know when the vertices it's drawing in 3D?

    1. It's specified as one of the arguments in gl.drawArrays.
    2. It's specified as one of the arguments in gl.bufferData.
    3. It's specified as one of the arguments in gl.vertexAttribPointer.
    4. It's specified as one of the arguments in gl.getAttribLocation.
    5. It's specified as one of the arguments in gl.enableVertexAttribArray.
  4. How does gl.drawArrays know when the color values are floats instead of ints?

    1. It's specified as one of the arguments in gl.drawArrays.
    2. It's specified as one of the arguments in gl.bufferData.
    3. It's specified as one of the arguments in gl.vertexAttribPointer.
    4. It's specified as one of the arguments in gl.getAttribLocation.
    5. It's specified as one of the arguments in gl.enableVertexAttribArray.
  5. How does gl.drawArrays know how many triangles are in a triangle strip?

    1. It's specified as one of the arguments in gl.drawArrays.
    2. It's specified as one of the arguments in gl.bufferData.
    3. It's specified as one of the arguments in gl.vertexAttribPointer.
    4. It's specified as one of the arguments in gl.getAttribLocation.
    5. It's specified as one of the arguments in gl.enableVertexAttribArray.
  6. Normalize this vector: (8,-6,0).

    1. (3, 4, 5).
    2. (3/5, -4/5, 0).
    3. (4/5, -3/5, 0).
    4. (4/5, 3/5, 0).
    5. (8, -6, 10).
  7. Find a normal vector to the plane through the points (1,0,0), (1,1,0), (1,0,1).

    1. (0, -1, 0)
    2. (0, 1, 0)
    3. (1, 0, 0)
    4. (1, 1, 0)
    5. (3, 2, 2)
  8. Which of these curved surface equation types makes it easy to generate points on the surface?

    1. explicit
    2. explicit and implicit
    3. explicit and parametric
    4. implicit
    5. parametric
  9. Which of these curved surface equation types makes it easy to test whether a point is on the surface?

    1. explicit
    2. explicit and implicit
    3. explicit and parametric
    4. implicit
    5. parametric
  10. What type of equation is this: \(x^2+y^2+z^2=1\)

    1. explicit
    2. explicit and implicit
    3. explicit and parametric
    4. implicit
    5. parametric

2   Homogeneous coordinates

My take on homogeneous coordinates. IMNSHO (In My Not So Humble Opinion) it's better than the book.

3   Textbook slides: Chapter 5

The big topic for Chapter 5 is homogeneous coordinates. They allow all the common transformations - translation, rotation, scaling, projection - to be expressed as a multiplication by a 4x4 matrix.

  1. 5_1 Representation - I'll do this really quickly.

4   Textbook programs

My local web copy .

My copy on RCS.

  1. Chapter 4:

    1. color interpolation
    2. element arrays
    3. etc

    We'll skip quaternions until we see 3D rotations.

CG Class 8, Mon 2019-09-16

1   No class this Wed

Pres Jackson is holding a faculty reception.

2   Homework due dates changed to Thurs

This is to allow you to get help during the week before handing them in.

This starts with Homework 2.

3   Course wiki reorganized

The landing point lists all the posts in order, newest first. Blog in the top menu does the same. Archive lists the titles of all the posts.

4   Airas office hours

Tues 11am, 1st floor of Folsom library near entrance. akhtaa2@ AT rpi DOT edu.

5   Today's iclicker questions

  1. A mouse reports which type of position?
    1. Absolute
    2. Relative
  2. A tablet reports which type of position?
    1. Absolute
    2. Relative
  3. Which of these can easily be a logical keyboard?
    1. a physical keyboard
    2. a tablet with handwriting recognition
    3. a virtual keyboard on the screen, selecting letters with the mouse
    4. voice input and recognition
    5. all of the above
  4. Which of these mode scales up better when there are many input devices, most of which are quiet most of the time.
    1. event
    2. request
  5. The X window system was designed to
    1. help Mulder and Scully keep track of their data
    2. implement a client-server graphics system for workstations
    3. make smart phone graphics programming easier
    4. be a proprietary hi performance IBM product
    5. succeed the W window system.
  6. Double buffering solves which problem:
    1. producing stereo images
    2. low memory bandwidth
    3. remote debugging PCs
    4. displaying from a frame buffer while it's being updated
    5. optimizing scheduling two elevators as a group

7   Picking

The user selects an object on the display with the mouse. How can we tell which object was selected? This is a little tricky.

E.g., It's not enough to know what line of code was executed to draw that pixel (and even determining that isn't trivial). That line may be in a loop in a subroutine called from several places. We want to know, sort of, the whole current state of the program. Also, if that pixel was drawn several times, we want to know about only the last time that that pixel changed.

Imagine that the image shows cars in the north lot. You select a pixel that's part of the image of a wheel nut. However there are many wheel nuts in the image, perhaps all drawn with the same subroutine. You might want to know that you selected the 4th wheel nut on the right front wheel of the 2nd car on the left of the 3rd row from the front.

There are various messy methods, which are all now deprecated. The new official way is to use the color buffer to code the objects.

  1. Decide what granularity you want for the selection. E.g, in the north lot, you may not care about specific wheel nuts, but just about wheels. You want to know that you selected the right front wheel of the 2nd car on the left of the 3rd row from the front.
  2. Assign each wheel in the lot a different id number.
  3. When drawing the scene, use each wheel's id number for its color.
  4. Look at the contents of the color buffer pixel to know what you picked.
  5. Perhaps really store this info in a 2nd buffer parallel to the color buffer, so the image will look better.

8   Next few lectures will be mostly mathematics

I'm replacing the Angel lecture at Incremental and Quaternion Rotation, with my own material. Feel free to read ahead.

CG Homework 3, due Thurs 2019-09-26 2359

Homework 3, due Thu 2017-09-26 2359

  1. (10 pts) Part of changing from one coordinate system to another is scaling and making things fit. E.g., suppose that you had a square with lower left corner (llc) (0,0) and upper right corner (urc) (1,1). You want to scale and center it to just fit into a rectangle with llc (0,0) and urc (2,3). The square stays a square but is probably larger or smaller. Then, these equations would do it:

    x' = 2x
    y' = 2y + 1/2

    This question is to figure out how to make a rectangle from (0,0) to (2,3) fit into a square that is from (0,0) to (10,10).

  2. (10 pts) Consider a pinhole camera as discussed in slide 12 of ppt presentation 1_5. Let d=2. To where does the point (1,3,-3) project? Use the equation on that slide. x/z/d should be parenthesized as x/(z/d).

  3. (5) If your image has only 64 different colors across the whole image, how many bits per pixel do you need for the color buffer?

  4. (25) Extend your program from last week that displays the Starship Enterprise as follows:

    1. Add 3 sliders that will rotate it around the X-axis, Y-axis, and Z-axis respectively.
    2. Do the rotations the simplest (and least efficient) way. I.e., in your javascript program, have render rotate the matrix and resend it to the GPU.

(Total: 50 points.)

CG Class 7, Thu 2019-09-12

1   Iclicker questions

  1. If you want your javascript program to send a color for each

    vertex to the vertex shader, what type of variable would the color be?

    1. uniform
    2. varying
    3. attribute
    4. dynamic
    5. static
  2. When one neuron in your retina receives a lot of light, that causes the neighboring neuron to

    1. be more likely to fire
    2. be less likely to fire
    3. be unaffected by this neuron.
  3. In the graphics pipeline, the step after rasterizing is the

    1. vertex shader
    2. primitive assembler
    3. fragment shader
    4. tesselation shader
    5. javascript callback
  4. The spectral wavelength of pure purple is about

    1. 400 nm
    2. 500 nm
    3. 600 nm
    4. 700 nm
    5. There is no wavelength for pure purple.
  5. What is your favorite platform/OS?

    1. Windows
    2. Linux
    3. Mac
    4. Android
    5. Other
  6. The carpet is an example of

  1. diffuse reflection
  2. specular reflection
  3. environment mapping
  4. bump mapping
  5. how to save money

2   Text chapter 3 programs

http://homepages.rpi.edu/~frankwr/ECSE-4750/CODE/03/ (corrected)

triangle, cad1 and cad2 are simple interactive drawing programs.

CG Class 6, Wed 2019-09-11

1   Iclicker questions

  1. Why does WebGL have the triangle-strip object type, in addition to the triangle type?
    1. It leads to smaller, faster, graphics objects.
    2. It leads to bigger, faster, graphics objects.
    3. It's not possible to split some complicated polygons into lots of simple triangles, but you can split them into triangle-strips.
    4. The standards writers were being paid by the word.
  2. What is the physical principle underlying LCD?
    1. Fire an energetic electron at a rare earth atom and a photon of light is emitted.
    2. Plowing your family farm as a kid can suggest an way to invent electronic television.
    3. A solution of corkscrew shaped molecules can rotate polarized light.
    4. Putting your finger close to a capacitor can change its capacitance.
    5. If two coils of wire are close, then an alternating current in one can induce a current in the other.
  3. Standards ...
    1. allow programmers to move between projects
    2. allow different types of hardward to be substituted in.
    3. ..... operating systems ......
    4. allow vendors to lock in customers.
    5. can prevent the latest HW from being used to its fullest.
  4. Color printing on a sheet of paper exemplifies
    1. additive color
    2. subtractive color
    3. multiplicative color
    4. divisive color
    5. exponential color
  5. Red is a primary color of which color space?
    1. additive color
    2. subtractive color
    3. multiplicative color
    4. divisive color
    5. exponential color
  6. Major components of the WebGl model as discussed in class are:
    1. Objects, viewer, light sources, planets, material attributes.
    2. Still cameras, video cameras, objects, light sources.
    3. Objects, viewer, light sources, material attributes.
    4. Colored objects, black and white objects, white lights, colored lights
    5. Flat objects, curved objects, near lights, distant lights.

2   SIGGRAPH 2017 videos

SIGGRAPH is the world's leading CG conference. I'll show various videos from it.

  1. BendSketch: Modeling Freeform Surfaces Through 2D Sketching.

    My local copies (MP4 and WEBM) are here.

3   Textbook slides

We'll continue with the textbook powerpoint slides.

  1. 3_1, Programming with WebGL Part 3: Shaders
  2. 3_2, Programming with WebGL Part 3: Shaders (2nd set with this title)
  3. 3_3, Programming with WebGL Part 4: Color and Attributes
  4. 3_4, Programming with WebGL Part 5: More GLSL
  5. 3_5, Programming with WebGL Part 6: Three Dimensions
  6. 3_6, Programming with WebGL Part 6: Three Dimensions ctd

4   Today's original demo program

For today's demo program, I'll modify triangle to add a slider that skews a vertex. Then we can maybe rotate.

5   Text chapter 3 programs

Now, we'll see how the programs in <https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/CODE/03/>`_ work.

triangle, cad1 and cad2 are simple interactive drawing programs.

File locations:

  1. Textbook site.
  2. My local web copy .
  3. There's another copy on RCS at /afs/rpi.edu/home/56/frankwr/public_html/ECSE-4750/Angel/7E/03
  4. which is also visible on the web.

CG Class 5, Mon 2019-09-09

1   How to print info from inside your javascript program

  1. There are several ways; here is the easiest.

  2. Reference: http://www.w3schools.com/js/js_output.asp

  3. Examples to do inside square.js:

    1. window.alert('this is an alert');
    2. window.alert('vertices length: ' + vertices.length + ' 1: ' + vertices[1]);
  4. Note that you can write variable values as well as strings.

  5. Another way is to write to the console log thus:

    console.log('this is a log message');

  6. In firefox, you can display the log window with F12.

  7. An advantage of the log is that you see all the messages together.

  8. I'll demo these methods.

2   Today's demo program

For today's demo program, I'll modify triangle to add a slider that controls the amount of green to add to the triangle color.

  1. The amount of green will be read from a slider.
  2. Scrounge your slider code from gasket5.
  3. The value will be transmitted to the fragment shader in a uniform variable.
  4. Scrounge around in Angel's examples to see how to use a uniform variable. (I grepped for 'uniform').

3   Textbook slides

We'll finish the Chapter 2 slides.

4   Iclicker questions

  1. What is your major?
  1. CSYS
  2. ELEC
  3. CSCI
  4. GSAS
  5. Other
  1. What is your class?
    1. 2020
    2. 2021
    3. 2022
    4. Grad
    5. Other
  2. What is the correct order of the graphics pipeline?
    1. vertex-shader fragment-shader rasterizer primitive-assembly
    2. fragment-shader rasterizer primitive-assembly vertex-shader
    3. rasterizer primitive-assembly vertex-shader fragment-shader
    4. primitive-assembly vertex-shader fragment-shader rasterizer
    5. vertex-shader primitive-assembly rasterizer fragment-shader
  3. If you wanted to change all the vertex positions by multiplying each x-coordinate by the same vertex's y-coordinate, the best place to do it is:
    1. with a javascript function
    2. in the vertex shader
    3. in the fragment shader
    4. in the html file
    5. it can't be done.

CG Homework 2, due Thurs 2019-09-19 (changed)

Homework 2, due Thurs 2019-09-19 2359

Rules

  1. You may work in teams of 2. Each team should submit their solution under only 1 student's name, but mention both people at the top of the submission. The other student's submission should just name the lead student. (This makes it easier for us to track things and to avoid grading it twice.)

  2. Hand in your solution on RPILMS. As for formats, we'll take (at least) a scanned image of a neatly handwritten page, raw text, PDF, and MS Word.

  3. For the programming question, pick whichever you prefer to get us the code:

    1. Submit a zipped file, containing your .js and .html files and the utility files needed to run it. It must be organized so that if we unzip into a random location and point the browser at the .html file, then it will work.

      It might be easier to move the utility .js files into the same directory as your code (and adjust the include lines).

    2. Put the code on a web server such as RCS.

Questions

  1. (5 pts) Which RPI grad was the technical person in the founding group of NVidia?

  2. (5 pts) What hardware component had to get much cheaper in order to make frame buffers possible?

  3. (5 pts) The progress of computer graphics has always been enabled by new hardware. One newish toy is Google Cardboard. Pretend that I've never heard of it, and write 100 words or so summarizing it and giving specific details.

  4. (20) Modify last week's program to display the spaceship NCC1701.

    1. The data is in the file ncc1701b.data . Each line gives the vertices of one triangle as follows:

      x1 y1 z1 x2 y2 z2 x3 y3 z3

    2. Insert the data into your javascript file and try displaying it.

    3. If this is too much data, then reduce the number of triangles until something displays. Report what went wrong, and how many triangles could be displayed.

    4. You might have to scale the data to fit. I'll let you figure out the easiest way to do that. The problem is that last week's square had coordinates in the range from -1 to 1, while the NCC1701 does not.

    5. Attach a PDF of any files you modified and a screendump. If the file has a multi-thousand line array, it's ok to delete the middle.

  5. (5) In real life, light bounces from object to object, on its way from the light source to the viewer. However, the OpenGL pipeline processes objects independently, and does not allow that (except the an object can hide another object). Why?

  6. (10) According to the tristimulus model, our eyes have three types of color receptors (cones). However several species and some rare human females have four types of cones. They are called tetrachromats.

    1. Name some such animals.
    2. For humans, why is it (probably; opinions differ) only females?

(Total: 50 points.)

CG Class 4, Thu 2019-09-05

1   Iclicker starts Mon

Bring your iclickers.

2   Linear algebra tutorial

  1. For students confused by the linear algebra questions on homework 1, the following may help:

    1. vector methods.
    2. Vector Math for 3D Computer Graphics
    3. Working with vectors, from Maths: A Student's Survival Guide
  2. Also see wikipedia.

  3. Some older graphics texts have appendices summarizing the relevant linear algebra.

  4. The scalar (dot) product is needed to do things like this:

    1. compute how a ball bounces off a wall in pong
    2. compute lighting effects (how light reflects from a surface)
  5. The cross product's applications include:

    1. compute torque and angular momentum.
    2. compute the area of a parallelogram.

    It is the only operator that you'll probably ever see that is not associative. Ax(BxC) != (AxB)xC.

  6. The triple product (A.BxC) computes the volume of a parallelepiped.

3   Protecting your RCS website

  1. By default, everything on https://www.rpi.edu/~RCSID/ is readable by anyone.
  2. Here's one way to add a low grade password.
  3. It relies on the facts that when a reader navigates to a directory.
    1. by default, the contents of the directory are listed, unless
    2. the dir contains the file index.html (or variants like index.htm).
    3. then that file is displayed instead of the directory contents.
    4. This behavior is controlled by various options in files like .htaccess, so there might be dirs where it doesn't happen.
    5. Nevertheless, except for that unusual case, the reader can't see the actual directory.
    6. However, any file (or subdir) that the reader knows about can be listed explicitly.
  4. So, do this:
    1. Create an empty file public_html/index.html
    2. Create a subdir with an unguessable name, like public_html/passw0rd/.
    3. Put your work in there.
    4. Its URL will be https://www.rpi.edu/~RCSID/passw0rd/
  5. There are also other harder ways to add passwords to directories.

4   Your RCS web files not visible?

  1. Read this if, when you browse to your public_html, you see only subdirs, not plain files.
  2. The problem is an AFS Access Control List (ACL) setting on the dir.
  3. See them thus in an ssh session: fs la .
  4. system:anyuser needs to be rl, not l.
  5. Sometimes the defaults are changed w/o telling anyone.
  6. Set the ACL thus: fs sa . system:anyuser rl (note the period).
  7. New subdirs inherit from their parents, but ACL changes do not propagate.
  8. So, you need repeat that command in any subdirs you already created.

5   Programming

  1. Serpinski gasket programs showing more complicated WebGL.

    We play with the code to see what changes.

  2. Notes:

    1. gasket4 shows how to do 3D with a depth buffer.

      Each pixel now stores

      1. RGB color of the object that was drawn at that pixel
      2. distance (depth) to that object.

      When a new object is drawn over that pixel, it replaces old color and depth only if the new object is closer. So, close objects hide distance objects.

      We'll ignore the problem of an object that covers only part of the pixel. (This is a big problem.)

    2. gasket5 shows an interactive program with a slider and callback. The user changing the slider causes a javascript function to be called.

  3. Graphics display hardware:

    The progress of Computer Graphics is largely the progress of hardware. We'll see more of this later. However, here's an intro.

    1. What physical principles are each type of HARDWARE based on?

      1. CRT: certain rare earth materials emit photons when hit by electrons. Explaining this is what got Einstein his Nobel (not relativity).
      2. LCD: electric field causes big asymmetric molecules to untwist so that they no longer rotate polarized light passing through them.
    2. What engineering challenges required solving?

      1. Shadow-mask CRT: electron beams travel varying distances at different angles, but don't hit the wrong phosphor even as the system gets hotter. The precision is 0.1%.
      2. Hi-performance graphics requires hi bandwidth memory.
      3. Virtual reality headsets require knowing where your head is and its angle (harder).

      Think of 3 ways to do this.

    3. What tech advances enabled the solutions?

      1. Raster graphics requires cheap memory.
      2. LCD panels require large arrays of transistors.
  4. Note on Engineering Grounded In Reality and famous graphics alumni.

  5. Executive summary of Portability And Standards.

6   Textbook slides

We'll continue with the textbook powerpoint slides.

  1. 2_2, Programming with WebGL Part 1: Background.
  2. 2_3, Programming with WebGL Part 1: Background
  3. 2_4, Programming with WebGL Part 2: Complete Programs
  4. 2_5, Programming with WebGL Part 2: Complete Programs
  5. 3_1, Programming with WebGL Part 3: Shaders

CG Class 3, Wed 2019-09-04

1   Yesterday's program demos

  1. I ssh'ed from my linux laptop to rcs.rpi.edu, which is a linux machine.
  2. My RCS copy of the textbook files is at ~frankwr/public_html/ECSE-4750 .
  3. The URL is https://rpi.edu/~frankwr/ECSE-4750/ .
  4. square.html and square.js are from Chapter 3.

3   Today's material

  1. Serpinski gasket programs showing more complicated WebGL.

  2. Extra material on colors

    1. Tetrachromacy

      Some women have 2 slightly different types of green cones in their retina. They see 4 primary colors.

    2. Metamers

      Different colors (either emitted or reflected) with quite different spectral distributions can appear perceptually identical. With reflected surfaces, this depends on what light is illuminating them. Two surfaces might appear identical under noon sunlight but quite different under incandescent lighting.

    3. CIE chromaticity diagram

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

      1. More info: http://wikipedia.org/wiki/CIE_xyY .
      2. Purple is not a spectral color.
    4. Color video standards: NTSC, SECAM, etc

    5. My enrichment note on NTSC And Other TV Formats. NTSC, the American analog TV standard, is now getting obsolete. However it was a beautiful example of engineering design. First B&W TV was invented. Then color was added in a way that was upward compatible, downward compatible, and used no more bandwidth.

    6. Failed ideas: mechanical color TV. http://en.wikipedia.org/wiki/Mechanical_television (enrichment).

    7. Additive vs subtractive colors.

      1. http://www.physicsclassroom.com/Physics-Interactives/Light-and-Color/RGB-Color-Addition/RGB-Color-Addition-Interactive
    8. Sensitivity curves of the 3 types of cones vs wavelength.

      1. http://i.stack.imgur.com/5snTb.png
    9. Material reflectivity vs wavelength.

    10. Incoming light intensity vs wavelength.

    11. Retina is a neural net - Mach band effect. When one cone is brightly lit, it inhibits its neighbors from firing so easily. This acts like a high frequency filter, to emphasize small details in the scene. Note: the details of how this works are uncertain.

    12. I'll do in class:

      Week 2, set 1, Models and architectures

4   Homeworks

  1. I'm using LMS only for submitting homework and recording grades. The text of the assignments will be only on the course page.

    The reason is that LMS is really badly designed. E.g., entering a formula into its spreadsheet requires clicking on a menu (you cannot type the formula), and the formula cannot be edited.

CG Class 2, Tues 2019-09-03

1   Wed 2019-09-03, Class 02

1.1   Piazza

We now have a class Piazza discussion, with this signup page. I enrolled everyone who pre-registered. Post your non personal questions here. You are encouraged to answer other students' questions. I may answer questions that remain unanswered for too long.

Part of your grade depends on answering some questions.

1.2   Homework 1 notes

  1. You may use any (legal) webserver.
  2. If using rpi.edu, you may use any (legal) upload technique.
  3. Because of resource limits, rpi.edu's config has been known to change w/o notice. Also, my view of it can be different from the student view. E.g, students do not automatically get AFS access. However, the following points may help.
  4. Mac users: ssh to rcs.rpi.edu with terminal.
  5. Windows users: install putty. Unfortunately I'm not allowed to install SW on the classroom PC and so can't demo it.
  6. Linux: run ssh to login to rcs.rpi.edu.
  7. For copying files:
    1. For a few small files, cut and paste.
    2. Windows: install winscp or filezilla.
    3. From inside your rcs account: wget copies the contents (files or dirs) specified by a URL.
    4. With an AFS client program, your RCS directory is read and writable from another computer. On linux, that's the openafs-client package.
    5. From any OS, you may be able to mount your RCS dir as a share thus: sftp://rcs.rpi.edu .
  8. Other platforms: ?
  9. Today I'll demo the program in the homework and help in getting started.

1.3   Angel

  1. Angel's slides should be here: http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SEVENTH_EDITION/PPT/

    or https://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SEVENTH_EDITION/PPT/

  2. Since that is not always working, use my local copy:

    https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/

    Commentary: It is a myth that material on the web lasts forever. I have many counterexamples, even for pages I've used in this class over the years.

  3. Read week 1, sets 1-4 on your own.

  4. I'll do in class:

    1. Week 1, set 5, Image Formation

CG Homework 1, due Mon 2019-09-09, 9am

Hand in your solution on RPILMS. You may work in teams of 2. Each team should submit their solution under only 1 student's name, but mention both people at the top of the submission. The other student's submission should just name the lead student. (This makes it easier for us to track things and to avoid grading it twice.) As for formats, we'll take (at least) a scanned image of a neatly handwritten page, raw text, PDF, and MS Word.

  1. (4 pts) One graphics pioneer was Ivan Sutherland. Name an influential tool that he created and an influential algorithm that he helped create.

  2. (4) Consider these 3-D vectors: A=(0,4,2), B=(1,2,5), C=(8,7,9). Compute:

    1. A.(BxC)
    2. (AxB).C
  3. (4) (This is another a test of your linear algebra knowledge. Feel free to refer to books to find the correct formulae.)

    Suppose that we have a plane in 3-D thru the points A(4,2,0), B(3,2,0), and C(0,1,3).

    1. What is its equation, in the form ax+by+cz+d=0 ?
    2. Consider the line L thru the points O(0,0,0) and P(1,1,1). Where does this line intersect the plane?
  4. (4) Modify the program in https://wrf.ecse.rpi.edu/Teaching/graphics/SEVENTH_EDITION/CODE/CLASS/square.html that calls several other files, to display shapes that are the first initials of the last names of the team members.

    1. Assume that your RCSID is STUDENT. In the following, replace STUDENT with your RCSID.
    2. From an RPI windows machine, click the AFS RPI icon create a share with your RCS files.
    3. Go into public_html.
    4. Create a folder called homeworks.
    5. Copy the folder https://wrf.ecse.rpi.edu/Teaching/graphics-f2016/SEVENTH_EDITION/CODE/Common/ into homeworks.
    6. Create a subfolder homework1 under homeworks.
    7. Copy files https://wrf.ecse.rpi.edu/Teaching/graphics-f2016/SEVENTH_EDITION/CODE/CLASS/square.html and https://wrf.ecse.rpi.edu/Teaching/graphics-f2016/SEVENTH_EDITION/CODE/CLASS/square.js into that folder.
    8. Change them to answer the homework.
    9. Look at your answer by browsing to https://www.rpi.edu/~STUDENT/homeworks/homework1/square.html

    When you've solved that question:

    1. Put your answers to all the homework questions in some file, even on your own PC.

      Include listing for the files you changed for square.

      Mention the URL to access your modified square, e.g., https://www.rpi.edu/~STUDENT/homeworks/homework1/square.html

    2. Upload that file of answers to LMS.

    I will be glad to help with any problems.

  5. (2) Do exercise 1.1 from the textbook, page 37.

  6. (2) Do exercise 1.8 from the textbook, page 38.

(Total: 20 points.)

CG Class 1, Thurs 2019-08-29

Thurs 2019-08-29, class 01

  1. Discuss Syllabus.

  2. Intro to OpenGL.

    1. It's a platform-neutral competitor to DirectX. See http://en.wikipedia.org/wiki/Comparison_of_OpenGL_and_Direct3D .
    2. The competition improves both.
    3. The designers made a decision to do ''only rendering'', no input, audio, or windowing.
    4. The OpenGL standards committee gradually adds and subtracts features.
    5. The goal is to exploit the latest GPUs while keeping the size manageable.
    6. This makes the ''hello world'' program much longer, but makes complicated graphics more efficient.
    7. OpenGL4 exploits latest GPU features. However many expensive business laptops cannot run it.
    8. OpenGL4 being lower level opens a niche for a replacement easy-to-use graphics API. I recommend Qt.
    9. Tools like Blender are higher-level, very good for realistic scenes, but too fancy for simple graphics programming. I'll leave them to other classes.
    10. See http://en.wikipedia.org/wiki/Opengl .
    11. WebGL is an API for HTML5.
    12. This course uses JavaScript because web-based graphics is easier with it.
    13. Although JavaScript is less efficient than C++, the serious graphics computing is done on the graphics card.
    14. The OpenGL API for C++ is quite similar to JavaScript's. Instead of the JavaScript framework, you need a C++ toolkit to provide the the higher level functions that OpenGL chose not to provide. This includes creating windows. GLUT is one such toolkit. It is widely used but old. There are other newer ones.
  3. Why is this course different?

    1. Shader-based

    2. Most computer graphics texts use OpenGL but still use fixed-function pipeline, don't require shaders, do not make use of the full capabilities of the graphics processing unit (GPU).

      If you see references to glBegin and glEnd, that book is obsolete by 10 years.

    3. Web: With HTML5, WebGL runs in the latest browsers. Makes use of local hardware, No system dependencies.

  4. Some web resources

    1. http://www.cs.unm.edu/~angel/
    2. http://www.cs.unm.edu/~angel/WebGL/7E
    3. http://www.opengl.org
    4. http://get.webgl.org
    5. http://www.kronos.org/webgl
    6. http://www.chromeexperiments.com/webgl
    7. http://learningwebgl.com
  5. Long history of attempts at a good API described in text.

  6. OpenGL, 1992:

    1. platform-independent API that was
    2. Easy to use
    3. Close enough to the hardware to get excellent performance
    4. Focus on rendering
    5. Omitted windowing and input to avoid window system dependencies
  7. OpenGL evolution

    1. Originally controlled by an Architectural Review Board (ARB)
    2. Members included SGI, Microsoft, Nvidia, HP, 3DLabs, IBM,…….
    3. Now Kronos Group
    4. Was relatively stable (through version 2.5)
    5. Backward compatible
    6. Evolution reflected new hardware capabilities
    7. 3D texture mapping and texture objects
    8. Vertex and fragment programs
    9. Allows platform specific features through extensions
  8. Modern OpenGL

    1. Performance is achieved by using GPU rather than CPU
    2. Control GPU through programs called shaders
    3. Application’s job is to send data to GPU
    4. GPU does all rendering
  9. Immediate Mode Graphics

    1. Geometry specified by vertices
      1. Locations in space (2 or 3 dimensional)
      2. Points, lines, circles, polygons, curves, surfaces
    2. Immediate mode
      1. Each time a vertex is specified in application, its location is sent to the GPU
      2. Old style uses glVertex
      3. Creates bottleneck between CPU and GPU
      4. Removed from OpenGL 3.1 and OpenGL ES 2.0
  10. Retained Mode Graphics

    1. Put all vertex attribute data in array
    2. Send array to GPU to be rendered immediately
    3. Almost OK but problem is we would have to send array over each time we need another render of it
    4. Better to send array over and store on GPU for multiple renderings
  11. OpenGL 3.1

    1. Totally shader-based
      1. No default shaders
      2. Each application must provide both a vertex and a fragment shader
    2. No immediate mode
    3. Few state variables
    4. Most 2.5 functions deprecated
    5. Backward compatibility not required
      1. Exists a compatibility extension
  12. Other Versions

    1. OpenGL ES
      1. Embedded systems
      2. Version 1.0 simplified OpenGL 2.1
      3. Version 2.0 simplified OpenGL 3.1
      4. Shader based
    2. WebGL
      1. Javascript implementation of ES 2.0
      2. Supported on newer browsers
    3. OpenGL 4.1, 4.2, …..
      1. Add geometry, tessellation, compute shaders
  13. Source of much of this material: slides accompanying the text.

  14. Reading assignment: Angel, chapter 1.

  15. Homework 1 is online; due next Thurs 9am.

  16. Next Wed Sep 4 will be a lecture and SW session, held in the usual lab room.