Distance Field Raymarcher for Unity
This is an implementation of Distance Field Raymarching in the Unity game engine. It was created to be used as a reference implementation in future projects. For a comprehensive technical writeup about how Distance Field Raymarching works, see this article on my blog.
Below are a few of the major features of this implementation:
- Complete Implementation of Distance Field Raymarching. This repository demonstrates how to construct a fully working implementation of Distance Field Raymarching. Using this repository as a base, you can focus on implementation details instead of the more technical aspects of raymarching. Additionally, I include a number of useful Distance Field primitives (sphere, box, torus, cylinder, etc) and Combine Operations (Union, Intersection, Subtraction) - see
DistanceFunc.cgincfor details. Below is a gif of the included demo scene:
- Interaction with mesh-based Objects. This implementation takes Unity's depth buffer into account, so your raymarched objects can intersect and interact with traditional mesh-based objects.
- Heatmap-based Performance Testing. The system has support for heatmap-based performance testing using a color ramp. Below is an example of this output (red = many samples per pixel, blue = fewer samples):
- Open Source and License. This implementation is released under the liberal MIT License, so it is easy use it in your projects.