I’m interested in rendering some simple liquid 3d mass, literally only really interested in something that vaguely looks as though it could possibly be liquid. I.e. no-where close to anything properly simulated. It’d be neat of blobs could float apart/together, but even that isn’t required. Just a watery mass in zero gravity is kind of enough.
I noticed that cinders landing page (https://libcinder.org/) has something that actually looks a little along what I might want, but I’ve no idea where it’s from…?
Anyone got any ideas?
Looks like metaballs to me. I know that Hai shipped a closed source block back in the day for doing the meshing but i’d very much doubt it still works.
Effectively you’re dealing with 3d distance fields / functions. There’s 3 parts you need to consider:
The motion of the particles, might be able to get away with some simple noise / brownian motion, but if you’re not going for accurate simulation this is the easy bit
Meshing. This is the process of taking the isosurface of your distance field and turning it into a rasterisable mesh. Typically this is done using marching cubes or surface nets. There’s possibly newer and better algorithms out there but these are the two I know of.
Rendering. You want to be able to generate good normals and a decent resolution mesh to facilitate this as much as possible, but being a reflective and refractive surface it’s difficult to get right. Again, depending on your level of required realism you might be able to get away with an environment map and some
refract calls in a fragment shader, but this problem scales up quickly.
Generating usable UVs is really tough for a moving isosurface so hopefully you don’t need to texture the generated object. I have used triplanar mapping to texture dynamic metaballs for a project before with varying levels of success, so your mileage may vary with that technique.
The good news is that it’s a largely solved problem so there’s tonnes of reading material and sample code for you out there.
Appreciate the all the details @lithium .
Your description is very helpful as is your breakdown. I agree with your analysis and it feels like this is definitely a multi-week problem for me, if not perhaps multi-month, despite the amount of available resources. I’ll see if I can’t make something far simpler for my one use-case, but metaballs does look like a great next step should I find the time.
Thanks again @lithium !
You could also try your luck with a bit of raymarching
Appears the site is currently down - will check soon. Much appreciated @paul.houx !