I am too tired to explain this one right now, but I guess it is pretty easy to understand what it does from the playground? Happy to answer questions!
Impressive work !
Is the little sphere at center of the cube intented ? I feel like a lot of noise comes from it
Thanks @Tricotou! I should explain a little about the algorithm for the sphere to make sense.
Basically, this method shrink-wraps an icosphere or other arbitrary triangular hull inward against an isosurface / distance field. It is designed to be good at capturing fine details of a manifold and convex surface with customizable LOD. It can’t handle holes or areas that are too occluded from the initial inward projection (that’s why everything goes nuts when the shapes are separated too far).
More detail:
It does it in multiple passes, where pass / generation 0 is the base / primitive geometry of the hull, and future passes operate on vertices that were added in increasingly further subdivided versions of the hull.
Each refinement pass calculates positions for each new intermediate vertex (in parallel) by ‘surfing’ the isosurface between its parents to find the maximum deviation (height difference relative to parent vertex normals (which were calculated in the previous pass or base geometry).
Why the silly little sphere in the center? Well, because we initially blast rays inward from a sphere (to ensure valid starting topology) the rays actually have to collide with something, which means the isosurface scene has to occupy the 0,0,0 point somehow, otherwise those rays go off on a journey to outer space (I will make a cleaner fix). The artifacts were much worse without the sphere, but it is a very stupid fix
Adding iso surfaces like Dual Contouring to Babylon has been on my radar for a little while now.
I did it for this 64Kb demo and it works great:
so cool cc @Evgeni_Popov
Great, something reminded me of the picture of a head with an open mouth associated with the album The Prodigy Music for the Jilted Generation.
I think it would be cool to program something like this for babylon.js… But I have other plans, I will finally create a quantum foam!
That’s so cool! Did you do CPU or GPU implementation of dual contouring? I have a WIP playground for DC on WebGPU
But I would drop it so so happily if someone has already done the honors. These geometry algorithms are really brain numbing
In your demo I assume the noise / terrain is meshed through dual contouring? And is your film inspired by Big Buck Bunny of the Blender world? Super cool art style, and so many elements of Babylon used if this is Babylon!
Dual contouring is CPU: Generate mesh at startup then deform it using skinning.
Everything is in this article : Dual Contouring Tutorial – BorisTheBrave.Com
I had something a lot less terrifying in mind, like this: https://youtu.be/ru3uhLBzMnk?t=39
.. and what is quantum foam?