February 2019
Intermediate to advanced
292 pages
6h 55m
English
Okay. Take a look at the program you wrote at the end of the previous chapter, the one where you drew the silhouette of a sphere on a canvas. It’s time to revisit that and turn the silhouette into a full-on 3D rendering. Make the following changes to that program:
Assign a material to your sphere. The following material will give you a sphere that looks like the illustrations in this chapter.
| | sphere.material ← material() |
| | sphere.material.color ← color(1, 0.2, 1) |
Add a light source. Here’s one possible configuration, with a white light behind, above and to the left of the eye:
| | light_position ← point(-10, 10, -10) |
| | light_color ← color(1, 1, 1) |
| | light ← point_light(light_position, light_color) |
In the loop where you cast your ...
Read now
Unlock full access