How to implement Unity Metaballs?

Viewed 1489

I am trying to create a slime in my game and I found that metaballs may be a good way to approach this. I am having a hard time learning about them and I could do with some guidance. Does anyone know where I can learn about 3D metaballs or even an asset that is compatible with URP?

2 Answers

The way to achieve the metaballs stuff is by a technique called raymarching. This is a technique that does not use the clasical approach vertex points and passing info from the vertex shader to the fragment shader.

Everything is written in the fragment shader so there is not explicit vertex geometry, with the respective pros and cons, meaning that things done with classical vertex approach can be difficult to achieve with raymarching techniques in the fragment shader, for example precision of the points and the geometries in the scene or exporting models to use in other programs (need to achieve a mesh with vertices to export). On the other hand the metaballs stuff and the geometry melting/slimery things achieved with this technique should be quite ambitious to achieve through the classical approach (vertices, meshes, polygons, etc).

There is an active community powering this technique called shaderToy that shows what can be achieved with this technique, showing also that to achieve similar results with this specific approach would be much more difficult (and viceversa).

Find a metaball example here.

Also consider that the examples you might find in shadertoy are written in GLSL. To make those work out in unity, you would need to pass the GLSL code to HLSL that is the shader language unity uses. They are similar languages and usually having a cheatsheet with the respective equivalence in the languajes you can succeed on that. Interesting resource for that here.

An asset that can implement this approach might be this one but I am no sure.

Related