Rendering Signed Distance Fields in Real-Time

Mandelbulb

I built a simple ray-marcher using OpenCL that allowed for real-time visualisations of SDFs.

The Basic Premise

The goal in this project was to get a feel for using OpenCL with OpenGL interop to allow for more expensive computations to make use of the GPU. One example that came to mind was raymarching, a topic I quite like exploring, and which is traditionally done on the CPU.

Project Setup

The raymarching is done using OpenCL, but scene descriptions are contained in an included file -- this way there's no need for recompilation when I want to change what's being rendered.

The first basic functionality implemented was simple raymarching, including outputs for depth and step count. Depth is remapped dynamically based on the near and far planes, and the step count is visualized using a naive remapping function.

Following this was the addition of camera controls, tested by creating a slightly more complicated scene containing multiple SDFs. At this point support for lights and materials in the scene description was added; camera controls use delta time to avoid framerate dependency. It is expected that the scene file define the max steps to march, a soft shadow factor, the gamma correction factor, steps to be used for ambient occlusion, the distance from the surface at which to start marching to calculate ambient occlusion, an ambient occlusion factor, and the number of AA ssamples. Along with this, the scene description should contain definitions for the background, material (materialID, diffuse color, specular color, and specular coefficient), light color & direction, dome light, and the mapping of points to materials.