Course:CPSC312-2021/Ray Tracing Demo

From UBC Wiki

Authors: Theo Scofield, Yang Liu

What is the problem?

Given a list of objects in a 3D scene, render an image of the scene using ray-tracing into an image file.

The code should be easy to modify to add/remove/adjust objects in the scene.

What is the something extra?

We will combine individual renders into a dynamic animation using Haskell. For example, the standard reflective sphere oscillating above a checkerboard grid, showcasing moving reflections. If there's enough time, we might add more types of shapes as primitives.

What did we learn from doing this?

We found that Haskell was very slow at rendering images using ray tracing. For large images, it was on the order of ~10 seconds per frame. But there were some benefits of using Haskell as well. Where in another language we might have needed to make all sorts of constructors and destructors to represent various different kinds of objects, in Haskell, an object could simply be a function. And the fact that objects are functions makes them easy to compose; a list of ray-traceable objects can be input into a function that turns it into a single ray-traceable object very easily.

Anyway, here are some renders. Click on them to see the full animation. Every decision of what color each pixel should be was made in Haskell, but the work of saving the GIF was done by a java process that Haskell started up and talked to.

Bobbing.gif
Floormoving.gif
BobbingFloorMoving.gif
orbiting.gif

Links to code etc

https://github.com/lynch-liu/cpsc312-raytracing