Yeah, 3D fractals are awesome. But then, why do you rarely see procedural rendering used in games? I mean, raymarching unlimited objects in real-time seems really useful, right? Well, the problem is: Sure there's efficient ways to draw these objects, but how do you actually interact with them? Well, I'm gonna show you Marble Marcher. It's a proof of concept to show that fractals aren't just fun to look at, but real
games can be built with them using a fractal physics engine. The download link and source code are in the description. If you want to understand how Ray
marching works you'll definitely want to check out my other video on that first,
otherwise some of this video might not make any sense. So what do we actually
need for a physics engine? The most critical and difficult piece is
collision detection, and that's why it's often the biggest source of glitches in
modern games. Collisions are fundamentally difficult, because the math
is complicated and expensive, so games make a lot of approximations, and they're
always trying to balance accuracy with speed. And even then, after a few thousand
objects, things typically start to slow down. Now we should have an opportunity
to do better, because rendering a fractal is really only rendering a single root
object with a bunch of transformations and folds applied to it. So how can we
transfer this to the physics? Remember how fractals have a really efficient
distance estimator? Well this is actually really useful. If our object is a sphere
with a radius, then just by checking the distance estimator, we can immediately
know if we're intersecting or colliding with the fractal if the distance is less
than the radius. So problem solved, right? Nope, knowing that you're colliding with
something isn't enough, because you also have to know how to react to the
collision and unintersect yourself, and it's not obvious how we would get that information
efficiently, so I'm gonna put a big twist on everything. Normally you compute folds
and transformations a bunch of times and then finally take the distance estimate
of a root object, but let's say instead of computing the distance, you compute
the closest point? Okay but the closest point on the root object isn't actually
that useful. Once we have it though, we can just unfold that point by undoing
all of the transformations until finally we have the closest point on the
original fractal. That means it's just as efficient as computing the distance.
Using that point, it now allows us to update the sphere so we know exactly the
optimal direction and amount it needs to move to avoid the collision, and that to
me was an amazing discovery. It allows extremely fast precise collisions with
infinite objects. That inspired me to make marble marcher, a marble racing game
where you race on fractal surfaces to reach the goal. Since everything is ray
marched, you can take advantage of a bunch of cool features, like reflection,
refraction, soft shadows, dynamic lighting ambient occlusion, and since nothing is
baked, not even the physics, we can actually have the entire fractal evolve
during gameplay, and everything just works. It even runs at 60 frames per
second, no problems at all, though you will need a really high end GPU for the
high resolutions. There's one caveat though, remember how we're dealing with
distance estimates. To have the physics work, that estimate needs to be really
accurate. A lot of fractals have perfect distance estimates, but some don't. I'm
not sure what causes this problem. I think it has something to do with using a
scalar instead of a Jacobian matrix in the estimate, but I just made sure to
pick only fractals that worked, so it wasn't a problem. And yeah, this game is
free and open-source, so I really hope you give the demo a try. It's truly
unique, and I've never seen anything like this before. I also really want to thank
the artist Petty Theft for doing all the music for the game and this video. Be
sure to check out his Soundcloud. And for anyone that dares to speedrun the game,
these are my personal bests so far. Thanks for watching, and have fun.
Well, there is my "make yourself feel stupid" video for the day.
Really cool.
Download link / Github: https://github.com/HackerPoet/MarbleMarcher
And here I am trying center a div...
This is really amazing
His game has quite high demands on your graphics cat for what he claims about "efficient distance estimator". I have to go to resolutions below 1000 pixels witdth and height for framerates above 60 fps.
He also has other really cool videos on yt. Check non-euclidian geometry, it's mind blowing.
Anyone have this pre-compiled for Windows machines? Or can it only compile for a Linux/Unix/Mac based system?
Edit: Nevermind, its linked in his description. Doh.
I love this. I am often pained by the thought that we are running multicore terraflop systems with physics engines (and so on) that are hardly superior to those we had back in the early 80's.
The efficiency of using fractals in games programming was established a long, long time ago.
Witness Rescue On Fractalus, which originally ran on 6502 based machines;
https://www.youtube.com/watch?v=FbZ-chrOgGg
Captain Blood (which featured many great innovations in a really unique hard sci-fi package, featuring an awesome symbolic alien language the player had to decipher (good luck understanding the digitised alien speech), used a similar approach to great success on 68000 based systems
https://www.youtube.com/watch?v=QFDl6Z7Ms_g
There's a little reverse engineering here;
http://bringerp.free.fr/RE/CaptainBlood/main.php5