Raytracing 2 - KD-Tree and Photons

Last ray/path-tracers I did were simple. No acceleration datastructure, no complex lighting methods. And, I never tried GO.

Raytracing & KD-Trees

This tracer only supports triangles. I wanted to keep it simple.
Drawback: rendering a sphere was slow. Thus, Instead of storing my tris in an array, I stored them in a KD-Tree.

A KD-Tree is a tree based data-structure. Each node has a bouding box, and each tri contained in the node or in the children is in that bounding box.
This enable our tracer to quickly discard branch of a model which won’t cross our ray.

Since I wanted to visualized my tree, I implemented a CPU rasterizer in this tracer. Here is a rendering showing the bounding boxes:

Depth of field demo

Clean output

KD-Tree demo

This project is far from finished. I still need to support indirect lighting and maybe use another shading model.

Code available on GitHub

Disqus comments