You can assume that the camera eye point is at the origin, and that the "film" is a square parallel to the xy plane, 1 unit wide and 1 unit high, centered at aim point [0,0,-3].
Your job will be to loop through your image, rendering each pixel in turn. At each pixel choose an appropriate point on the film square as an aim point. Then ray trace from the camera eye point through that aim point.
You should define the following collection of spheres as your model:
center_{x} | center_{y} | center_{z} | radius | color |
---|---|---|---|---|
-1 | 0 | -10 | 1 | red |
0 | 1 | -10 | 1.25 | green |
1 | 0 | -10 | 1 | blue |
0 | -1 | -10 | 1.25 | white |
At each pixel, determine which sphere is closest to the camera, by implementing the ray-sphere math we covered in class, and use the color of that sphere as the pixel color. If the ray at a pixel does not hit any sphere, then render that pixel as black.