Raytracing 2

#Gaming#Raytracing#Solo#Graphics

Aanish Bhirud

Rust Ray Tracer Project

Over the last month, I have been working on another ray tracer project based on The Ray Tracer Challenge. This book is language agnostic, so I decided to use Rust because I have been learning it for a while and wanted to try it out on a project. I have been really enjoying Rust so far.

What is it

This ray tracer project is a departure from the book's intended method. I used several of Rust's features to make the code more readable, maintainable, and performant. Some of the improvements include:

  • Utilizing multithreading to improve rendering speed.
  • Implementing better algorithms for matrix operations like LU decomposition.
  • Incorporating SIMD (Single Instruction, Multiple Data) for faster calculations.

Showcase

First Renders

These are the initial renders made by the ray tracer. Although they lack many features, they mark the start of the project. At this stage, the ray tracer only supports spheres and does not include reflection or refraction.

First Renders

Reflection/Refraction

Implementing reflection and refraction was a challenging and debugging-intensive task. It required diving deep into the code and making various improvements. After much effort, I managed to get it working, and it now provides realistic reflection, refraction, and total internal reflection. The image below shows a simple sphere with a glassy material.

Reflection/Refraction

Patterns

I added patterns to the ray tracer, including stripes, gradients, rings, and 3D checkers. This enhancement adds more visual diversity to the rendered scenes.

Patterns

More Shapes

In addition to spheres, I have added support for cones, cylinders, cubes, planes, and triangles. This expansion broadens the range of objects that can be rendered.

Shapes 1 Shapes 2 Shapes 3

Groups

Groups have been incorporated into the ray tracer, allowing shapes to be combined and transformed together. The image below shows a group of spheres and cylinders arranged to form a rounded hexagon.

Groups 1 Groups 2

Constructive Solid Geometry (CSG)

I have implemented constructive solid geometry in the ray tracer, enabling the combination of shapes using boolean operations. The image below demonstrates a union of two spheres.

CSG

Triangles

To enhance the complexity of the rendered objects, I created a parser for the Wavefront OBJ format. This allows the loading of models from other programs. The images below display a teapot and an airplane model.

Teapot Airplane

Future Plans

Moving forward, I intend to explore modern 3D rendering techniques using openGL and Vulkan. These technologies will enable me to delve deeper into the field of computer graphics and expand my skills.