Inspiration

The inspiration for this project trickled in over some time. Projects such as "Code Parades" Marble Marcher, and Sebastian Lagues Ray Marching Video got me really interested in this kind of rendering technique. There are many strengths and weaknesses to a technique like SDFs, they require specific tools to create models for, and are less general-use than standard rasterization. This niche is in fact exactly what I built "SDFunky" for.

What it does

"SDFunky" (A play on the Acronym SDF) is a very rudimentary SDF (signed distance field) 3D modelling software. It's approach to modelling is through a stack based system, not dissimilar to CAD software, where every shape added to the scene operates on the cumulative "field" produced by all the steps before it. This modelling software is designed to make it easy for users to create signed distance field objects.

How I built it

Having dabbled in CPU raymarching, I knew for this project I had to migrate over to the GPU lest I be rendering ad infinitum. And so I used the unity engine and compute shaders to accomplish this. The stack of operations is stored on the CPU, and worked on by the user, which then gets passed into the GPU for rendering via a compute shader. The GPU actually does the raymarching, specifically a variant called "sphere tracing", where a ray steps forward based on how far away it is from the nearest point in the scene.

Challenges I ran into

Surprisingly, the GPU implementation of sphere tracing went fairly smoothly, in fact, there weren't many major hitches in the development of the software. The main issue I encountered was the ambition of what I was attempting to do in a 2 day time span, and as such many parts of the project feel unfinished. The hardest part of the actual implementation was probably the stack instruction system which turned into a real rats nest of crossing global variables after the deadline started getting closer.

Accomplishments that I'm proud of

Getting GPU sphere tracing up and running properly, then calculating ambient occlusion (which basically comes free with sphere tracing) on top of the Phong reflection model. Getting it all working, and then plugging in the Mandelbulb distance estimator. Seeing that image of the 3D fractal with its waves of complexity, shrouded in ambient occlusion and shadowy goodness, you could almost reach out and touch it. That was an accomplishment I am proud of. When the ambience is occluded

What I learned

It's not always the most technically involved or cutting edge design that's hardest to implement. Sometimes the greater feat is in doing something seemingly simple and mundane in a thoughtful and forward thinking manner.

What's next for SDFunky?

Improvements improvements improvements. I really like the idea for this, so here's a couple of ideas I want to add now that I have more time:

  • JSON exporter, lets you save and share models / even import into other programs maybe!
  • Colour! The program's looking like a 1950s TV with the amount of monochrome on the screen.
  • Sweeping / revolving shapes to produce complex designs faster
  • Implementing the other things raymarching is well known for, repetition and symmetry!

Built With

Share this project:

Updates