Objective 15:
Makefile Optimized Build Settings and Discussion of All Optimizations


I was excited to find out that the Makefile I had been using all along had not been optimized! This Makefile was of course supplied to us with a -g debug flag to create executables with debug information. This was not required for the final renderings once I had completed development, so I switched to an optimized build using the -O2 flag instead.

I did not expect a drastic improvement, but this did have quite a decent effect. I changed the -g compiler flag (which creates a debug build) to a -O2 flag, which creates an optimized build. I also played around with processor-specific flags, and the omit-frame-pointer flag but this did not appear to have much of an effect as compared with the change from -g to -O2.


Accumulated Optimization Status Runtime
Initial Voxel Traversal with voxel size "guess" 12x12x12s 2752 seconds. (~46 minutes)
Voxel-Polygon Sub-Mesh Optimization 143 seconds (~2 and a half minutes)
Shadow Ray Voxel Optimization 35 seconds
Optimal Grid Size Calculation 24 seconds
Makefile Optimized Build Settings 10 seconds


I now have another image to show the optimizations up to this point.

Accumulated Optimization Status Runtime
Initial Voxel Traversal with voxel size "guess" 2x2x2s 19295 seconds. (~5.4 hours)
Voxel-Polygon Sub-Mesh Optimization not calculated (sorry)
Shadow Ray Voxel Optimization not calculated (sorry)
Optimal Grid Size Calculation 1044 seconds. (~17 minutes)
Makefile Optimized Build Settings 241 seconds. (~4 minutes)


In conclusion, my Raytracer uses the combination of the following 6 optimization methods:

  • Uniform Spatial Subdivisions
  • Voxel-Polygon Sub-Mesh Optimization
  • Shadow Ray Voxel Optimization
  • Optimal Grid Size Calculation
  • Multiprocessing
  • Makefile Optimized Build Settings

As mentioned above, I got a whopping (I think that's a decent word to use here) improvement of 275 times in render speed with my Venus De Milo mesh object, as compared with the initial Voxel implementation. Note that this is a bit inflated, as likely the initial Voxel implementation runtime was actually slower than just running the naive raytracing approach
because the initial code did not support sub-mesh components in Voxels. But all in all, these combined optimizations had a massive effect on render times.

The table scene shows a total speedup of 80 times, which is also much more than I initially expected.

To mention my Computer Graphics hero John Lasseter again, and his famous quote: "The art challenges technology and the technology inspires the art."... now that I have managed to make the Raytracer 80-275 times faster, I suppose that really just means that in the future I should strive to Raytrace images that are 80-275 times better that what I could Raytrace 3 weeks ago. :)

On that note, I decided to render 380 frames to create an Animation for my final Extra Objective.

Written by: Mike Jutan
CS 488 - Computer Graphics
University of Waterloo