
Marble Marcher: ray-traced real time game on the surface of evolving fractals - tiborsaas
https://codeparade.itch.io/marblemarcher
======
Liquix
This program utilizes a powerful technique called _raymarching_ , 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).

How do we 'march' rays without missing geometry? With the aid of _signed
distance functions_ , 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:

    
    
      float sdfSphere(vec3 p, float r)
      {
          return length(p) - r;
      }
    

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:
[[https://www.youtube.com/watch?v=ie4u2i_5OdE](https://www.youtube.com/watch?v=ie4u2i_5OdE)]

Approachable overview of raymarching & SDFs: [[https://jamie-
wong.com/2016/07/15/ray-marching-signed-distan...](https://jamie-
wong.com/2016/07/15/ray-marching-signed-distance-functions)]

Learn more:
[[https://iquilezles.org/www/articles/raymarchingdf/raymarchin...](https://iquilezles.org/www/articles/raymarchingdf/raymarchingdf.htm)]

~~~
dylan604
>Marble Marcher is entirely ray-traced in real time and is played on the
surface of evolving fractals.

That’s the very first line of the source page. So why do you say it uses
raymarching? Are these terms used interchangeably as in marching is a method
to do tracing?

~~~
petetnt
The source code is available on GitHub and it indeed does seem to use ray-
marching

[https://github.com/HackerPoet/MarbleMarcher/blob/d436b6f8006...](https://github.com/HackerPoet/MarbleMarcher/blob/d436b6f80068cfee6b00b515cb4c0b2704d49afe/assets/frag.glsl#L199)

~~~
wlkr
Additionally, it is mentioned in the video on the page.

------
ariehkovler
This captures two of my childhood computing obsessions. I spent so long
messing around with Polyray and generating raytraced pictures for convering
into Magic Eye stereograms. I also had some Windows 3.1 fractal generator
program, where you could mess around with the formulas and zoom in (slowly)
and make them cycle colours.

Looking forward to playing this a lot. I particuarly like the clever use of
fractal mathematics to make accurate collision detection physics. Though it
helps that he's using a sphere as the user-controlled object.

~~~
rzzzt
I played with Bryce 3D (from the MetaCreations era) as a child. Sooo many
generic landscapes.

~~~
rpmonteiro
you should checkout Tom Beddard, a master in the area, that has partnered with
the founder of MetaCreations. A little googling will show you some cool stuff.

------
llao
What a super well done video! Really benefits the game itself. Clear, concise,
intriguing and so positive. Can't wait to try this when I have time.

~~~
jonshariat
I'm constantly shocked at how well experts in their field can also teach,
explain, edit, and share their knowledge these days.

~~~
codeparade
Thank you!

------
tehsauce
A couple years ago I made very minimal game engine that allowed simple objects
to be intersected with SDFs for physics, a bit similar to this. It also had
some other cool ideas in it like 3d portals and gravity-bent rays of light.
This is the old version with pictures in the readme
[https://github.com/PWhiddy/Raymarch-
Engine](https://github.com/PWhiddy/Raymarch-Engine) And here is a version with
no pictures in the readme but an actual build system (if you want to try it
out) [https://github.com/PWhiddy/time](https://github.com/PWhiddy/time)

------
divs1210
This looks beautiful! Is the engine available as a library?

------
roadkillon101
Reminds me of Marble Madness
[https://en.wikipedia.org/wiki/Marble_Madness](https://en.wikipedia.org/wiki/Marble_Madness)
except with cool real time fractal generation. Definitely has potential.

------
czei002
Very cool. Think this game also used fractals:

[https://en.wikipedia.org/wiki/Rescue_on_Fractalus](https://en.wikipedia.org/wiki/Rescue_on_Fractalus)!

------
kaffeemitsahne
Reminiscent of the exploration scenes in Lem's Solaris, where the fractal-like
surface eruptions are explored by spaceship/plane. Unfortunately neither of
the movies had those.

------
Damogran6
My Pascal class in Highschool had a raytracing project for our amiga A500's. I
seem to recall a 320x200 view was split between 4-6 machines and it took 3-4
days to render.

------
dmos62
I ran this on my 2008 high-endish business laptop on lowest settings and it
ran at about 2 frames per second (though the indicator was showing 11) and
wasn't responsive. I love the idea, though.

~~~
airstrike
You'll need a dedicated GPU as the post says

------
vbuwivbiu
anyone compiled this for Linux/OSX ?

~~~
delinka
Or wasm?

~~~
anderspitman
Looks like it's using GLSL 400 shaders so I don't think it would work for wasm
unfortunately. Not sure how many non-WebGL features it's using though. Might
be straight-forward to port.

EDIT: bigger issue is probably that SFML apparently doesn't support wasm:
[https://github.com/SFML/SFML/issues/1494](https://github.com/SFML/SFML/issues/1494)

------
lbj
This ran at a very fluxating FPS but never below 120 in 1600x900 - So I think
you've done a very good job. Love the fractals!

