The Signed Distance Field Generator is a big part of my 3rd-year dissertation. The aim of it is to link two of the main rendering methods, ray-tracing and rasterization in a real-time rendering engine (Unity). Of course, achieving fully real-time ray tracing is something that we can only dream about for now. Therefore my implementation is focused on implementing some effects using ray tracing, these are soft shadows and ambient occlusion. In order to provide the algorithms with an optimized model of the geometry, I used a 3D voxel grid were each voxel contains the signed distance towards the closes triangle of the scene’s geometry. With this data, I was able to implement fast ray marching algorithm in order to query information about surrounding geometry like if a pixel is occluded by some other shape.
In order to compute the voxel grid which is called a signed distance field (SDF), I used Compute Shaders in order to move the processing to the massively parallel computing power of the GPU.
Another use-case that I discovered for the SDF is for quick collision lookups with particle sized object. In order to showcase this, I made a GPU particle system capable of spawning up to 4 million particles and each of them can quickly do collision detection with the geometry which was converted into an SDF. Check the video below to see it in action.