# CS 248: Final Solutions

## Question 5

5A (15 points)

Almost everyone got this question correct. In our canonical lighting model, we sum the contribution from each light. For each light, we sum the diffuse and specular terms. Since everything is just a sum of terms, it makes no difference in what order we sum them; as long as we have a specular and a diffuse contribution for each light, the resulting picture will be the same. Therefore, 1 and 2 are SAME, and 3 is DIFFERENT.

Criteria: -5 for each incorrect

5B (5 points)

This question was much simpler than it may have seemed. All that was asked for was a bit of code, using the given functions, that will fill the accumulation buffer with the original picture translated to the right by a fractional amount f, which ranges from 0 to 1. This should look familiar to you from the Image Processing assignment; this is just linear interpolation (not even bilinear). The new twist to this question is that, unlike the Image Processing assignment, we're not asking you to do the interpolation on a pixel-by-pixel basis; you can use the provided functions to do the interpolation for the whole image at the same time. `glAccum` lets you set the weight for the next draw operation, and `glDrawImage` draws the given image into the accumulation buffer, translated by `(dx,dy)`. Note that `dx` and `dy` are integers; if they were floats, we could simply say `glDrawImage(image,f,0)` and be done.

With that, the code snippet to do the interpolation is:

```glAccum (1.0 - f);
glDrawImage (image, 0, 0);
glAccum (f);
glDrawImage (image, 1, 0);
```

Criteria:

• -5 for a truly bizarre answer
• -4 if you didn't use linear interpolation at all
• -3 if you reversed the weights (shame on you)
• -2 for a minor mistake on the weights or translation amounts
• -2 if you ignored the given functions and described the computation for each pixel