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.
New stuff in those programs:
- Callbacks for mouse down, up, and motion.
- (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.)
- Now we'll see adding a second attribute variable - to represent each vertex's color.
- Another common possible attribute is a surface normal at each vertex.
- For each new attribute, define a new varying variable in the vertex shader.
- Give it some value probably computed from the attribute.
- The rasterizer will interpolate a value for each pixel from the values at the triangle's vertices.
- Define the same varying variable in the fragment shader to get that interpolated value.
- 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.
More iclicker questions.
More textbook slides from chapter 4.
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.
- 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.
- Assign each wheel in the lot a different id number.
- When drawing the scene, use each wheel's id number for its color.
- Look at the contents of the color buffer pixel to know what you picked.
- Perhaps really store this info in a 2nd buffer parallel to the color buffer, so the image will look better.