[WebGPU] Realtime Metaballs / SDF tessellation

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? :slight_smile: Happy to answer questions!


7 Likes

Impressive work ! :scream:

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 :laughing:

2 Likes

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:

10 Likes

so cool cc @Evgeni_Popov

1 Like

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.

7YQf

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!

1 Like

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 :sweat_smile:

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? :smiley: Super cool art style, and so many elements of Babylon used if this is Babylon!

1 Like

Dual contouring is CPU: Generate mesh at startup then deform it using skinning.
Everything is in this article : Dual Contouring Tutorial – BorisTheBrave.Com

1 Like

I had something a lot less terrifying in mind, like this: https://youtu.be/ru3uhLBzMnk?t=39 :laughing:

.. and what is quantum foam?

1 Like

Do you have code available somewhere? Would be interested to see how the performance is.

I’ve made a better POC of my GPU implementation:

(warning: this version is not complete, seams are handled lazily atm by just adding a padding sample on the higher (axially) face of each chunk)

1 Like