pc half

Fast CPU Raymarcher using SIMD

eth course where the goal is to increase performance of an algorithm taking into account cache and simd

Nihat Isik

ETH Course

Advanced Systems Lab is an ETH course focused on understanding how to make code fast. Taking into consideration the compiler, the cache and code vectorization.

Ray Marcher based on sphere tracing

We decided to build a Ray Marcher from scratch using only the c programming language and without needing to install any other library.
We also built a scene parser that allows for scenes to be defined with a simple .json file.

A ray marcher is optimal for rendering complex mathematical shapes. Or shapes that need to be approximated with polygons otherwise. A simple example is rendering a sphere. In the traditional way (ray tracing) we would shoot rays and collide with triangles. However the ray-marcher shoots rays and moves with a fixed (or dynamic in our case) step size until the signed distance function (SDF) becomes 0 or less. This SDF is the combination (the min function) of the signed distance function of all the shapes in the scene.

A very good resource for this is the following blog. It is very good for ray marcher or graphics related topics overall.
For more information over the algorithm and the optimizations you can read the report HERE.

Raymarcher Video Explanation

Raymarcher video explanation I programmed in Unity.

Vectorization example. Shooting 4 rays in one loop iteration. Notice the states of the rays changing when hitting an object.

Mandelbulb Example

Mandelbulb rendered using our raymarcher.

Report and Code

The report can be found here:


Github Repo