Marble Marcher: ray-traced real time game on the surface of evolving fractals
This program utilizes a powerful technique called <i>raymarching</i>, raytracing's big brother. Instead of tracing along each ray in tiny fragments and returning intersections, the ray is 'marched' in larger steps, vastly increasing render speed (the downfall of classical raytracers).<p>How do we 'march' rays without missing geometry? With the aid of <i>signed distance functions</i>, geometric equations which take an arbitrary point in 3space and evaluate to 0 if that point is on the 'shell' of the geometry. For example, the signed distance function for a sphere:<p><pre><code>  float sdfSphere(vec3 p, float r)
  {
      return length(p) - r;
  }
</code></pre>
This lets us do interesting things such as transform the point p to transform our object, take the minimum value of two spheres to produce a venn-diagram intersection shape, take the maximum of two spheres to 'cutout' a hole from one, etc. The logic is a bit backwards at first, but it clicks quite quickly and one can rapidly construct complex geometry without much optimization/shader magic. For example, this is a realtime capture of a 64k self-contained executable. No 3d models, no textures, no assets - just raymarching and math: [<a href="https://www.youtube.com/watch?v=ie4u2i_5OdE" rel="nofollow">https://www.youtube.com/watch?v=ie4u2i_5OdE</a>]<p>Approachable overview of raymarching & SDFs: [<a href="https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions" rel="nofollow">https://jamie-wong.com/2016/07/15/ray-marching-signed-distan...</a>]<p>Learn more: [<a href="https://iquilezles.org/www/articles/raymarchingdf/raymarchingdf.htm" rel="nofollow">https://iquilezles.org/www/articles/raymarchingdf/raymarchin...</a>]