title: Improving raytracer performance
body: <p>I'm writing a comparatively straightforward raytracer/path tracer in D (<a href="http://dsource.org/projects/stacy" rel="noreferrer">http://dsource.org/projects/stacy</a>), but even with full optimization it still needs several thousand processor cycles per ray. Is there anything else I can do to speed it up? More generally, do you know of good optimizations / faster approaches for ray tracing?</p>
  
  <p>Edit: this is what I'm already doing.</p>
  
  <ul>
  <li>Code is already running highly parallel</li>
  <li>temporary data is structured in a cache-efficient fashion as well as aligned to 16b</li>
  <li>Screen divided into 32x32-tiles</li>
  <li>Destination array is arranged in such a way that all subsequent pixels in a tile are sequential in memory</li>
  <li>Basic scene graph optimizations are performed
  
  <ul>
  <li>Common combinations of objects (plane-plane CSG as in boxes) are replaced with preoptimized objects</li>
  </ul></li>
  <li>Vector struct capable of taking advantage of GDC's automatic vectorization support</li>
  <li>Subsequent hits on a ray are found via lazy evaluation; this prevents needless calculations for CSG</li>
  <li>Triangles neither supported nor priority. Plain primitives only, as well as CSG operations and basic material properties</li>
  <li>Bounding is supported</li>
  </ul>