CG Lecture 14, Thurs 2016-09-29

  1. Shama's office hour tomorrow will end at 9:55 (however if you want to see her, go at 9). She will also be in class today after the lecture until 5:30.

  2. Handwritten notes on tablet from 09-28.

  3. More programs in <>.

  4. New stuff in those programs:

    1. Callbacks for mouse down, up, and motion.
    2. (Remember that an attribute variable is different for each vertex. I.e,., it's an attribute of the vertex. So far, the only attribute variable has been the vertex's position.)
    3. Now we'll see adding a second attribute variable - to represent each vertex's color.
    4. Another common possible attribute is a surface normal at each vertex.
    5. For each new attribute, define a new varying variable in the vertex shader.
    6. Give it some value probably computed from the attribute.
    7. The rasterizer will interpolate a value for each pixel from the values at the triangle's vertices.
    8. Define the same varying variable in the fragment shader to get that interpolated value.
    9. E.g., if the 3 vertices making a triangle have different colors, then the rasterizer will interpolate the color of each fragment, just as it interpolates each fragment's position.
  5. More iclicker questions.

  6. More textbook slides from chapter 4.

    1. Position Input
    2. Picking
    3. Geometry
  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.