As a small side project I built a ray tracer in Dart targeting the web, at the moment it only supports 1 primitive, the sphere.

It took an enormous amount of time to render this video, around 12 hours for 3600 frames at 3840x2160.

The reason it takes so long is because right now casting a ray checks intersection on every single object in the scene, this of course, is not even close to an optimal implementation. An easy way of speeding this up is to put objects in a BVH ( which would find objects based on log n rectangular prism intersection checks.

Lighting is also one of the biggest performance drains, right now it casts a ray to every light source, that means for every pixel it must check ray-sphere intersection at least 100 times per bounce. This can be optimized significantly by building a light map from photons and then using that light map to calculate surface lighting later when the scene is rendering. Using light maps instead of calculating light per-pixel would also give soft shadows and indirect lighting, something it desperately needs.

Source code: