Ray-tracing from scratch part 3: complex shapes and partial reflections
Enhancements#
This iteration of the 3D ray-tracing graphics engine (see previous) adds the following features:
- Multiprocessing
- Ray-tracing is inherently parallelisable: you have millions of rays that are all independent of one another. We achieve an “easy” 5-10x performance increase by using as many cpu cores as possible.
- Anti-aliasing
- I experimented with a few different algorithms, and found that multisample anti-aliasing worked very well. This involves firing multiple rays for each pixel and averaging out the result. I clawed back some performance by detecting when anti-aliasing was required (severe edges), and only subsampling for affected pixels.
- Real-time rendering
- I created a new window-mode so that the user can control the camera in real-time.
- Compound shapes
- I added some functions for building up complex shapes from primitives. Below you can see how I created a diamond from lots of triangles.
- Split rays
- Light doesn’t choose between absorption, reflection, and refraction. In reality it will do all three.
Read other posts