Metaballs for VRay

I decided to try and write rendertime metaballs for VRay. Basicly what you get with Blobmesh but infinitely smooth and nearly zero memory consumption, rendering million particles shouldn’t be a problem.

I’ll report progress here if anything comes out of it. Here is the first “proof of concept” screenshot rendered with VRay.

http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_02.jpg

Dieter Morgenroth already something similar with his tests. If I’ll ever finish the stuff I’ll probably release it as open source.

That looks great.
Keep the good work.
I always wanted to do something similar but didn’t have time to really try it.

Best regards,
Daniel

Awesome…if ya need any help testing let me know.

That does sound really cool.

Sounds interesting indeed. Would be great if it could replace the Glu3d one too. Will it support motion blur/motion vectors?

Hey there. Nice initiative Bercon as usual!

Dieter’s implementation is actually not only a test anymore. We’re actively using it in production every now and then (to render quite some water stuff for a recent job for example). The latest public build is still available for free and not timebombed anymore if i recall right. Does moBlur and works with PFlow systems.

Kind Regards,
Thorsten

I read this as ‘Meatballs for Vray’!

Hi,

the metaballs are not on the site. I only have the VRayISO there. The Blob stuff was partly developed at mackevision and because of that I am not allowed to either release it or make it open source. Sorry for that.

Dieter

I’ll probably start with static version and if it comes out fine I’ll make one which supports motion blur. Atm I don’t really even know where to start with the dynamic version. Could you point me in the right direction dimo?

I’ll try to make mine take in any point clouds, this includes all particle systems and meshes (verties). And perhaps support for maxscript so you could write import for practically anything.

Hi Dieter,
just to know, your great VRayISO is stop to the on 3dsmax 9 and 2008 for VRay 1.5 SP2. Any upgrade in the future?

To make it dynamic I stored both the position at the beginning of the interval and at the end of the intervall for each particle. When VRay gives you the ray to intersect, it will also give you the time value which you can use to interpolate the position for each particle. Codewise it’s no big difference to the static version, of course slower in rendering.
Most important thing is to use an acceleration structure for the point cloud and to have some kind of early termination. I used a BvH, which worked fine.
My approach calculated the surface new for each ray, which leads to perfect smooth surfaces.
This was very fast for opaque materials, because of the early termination. Another advantage was that it immediately starts rendering without the delay of setting up a mesh, and if your metaballs are not seen by camera rays they won’t waste time with mesh tesselation.
The problem I had was that if you have a refractive material like water and a lot of particles in your ray, you have to do a lot of calculations, and it get’s very slow.

At the end, for water it may be more efficient to tesselate to a rendertime mesh.

Dieter

So you built BvH with bounding boxes and to check which points where near enough?

Did you use it also to trace intersections to find if any points were along the ray and then started marching iterativly from the first bounding box intersection forward? Or does VRay already do this for me since my blobmesh supports splitBounding box methods and is splitable?

Also what kind of potential function did you use?
Mine uses the one I found here: http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/implicitsurf/
Function: http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/implicitsurf/implicitsurf2.gif

My system doesn’t have any optimzations at all so its pretty slow even with few particles but now it accepts PFlow as input.

http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_03.jpg

I tried to find some good papers on the matter but I didn’t find anything usefull. So here is what I’m thinking now.

http://www.niksula.cs.hut.fi/~jylilamm/graphics/Thinking\_01.jpg

First build up BVH with Boxes like the black boxes in the image. I can use them to optimize getting near points for field calculation and I can use them to avoid interating any rays that don’t intersect with leafs of BVH. Is this a good way to do it?

I was thinking of first creating bounding box for the entire point cloud, then splitting it in half again and again until I reach required depth or small enough leaf size.

The second optimization that comes to mind is that I could intersect the Outer Bound spheres of the all points that I get when intersecting BVH. This would futher narrow down my need to iterate the potential field.

Third optimization would be for transparent metaballs. When ray starts inside the field instead of starting to move normal iteration steps I could directly jump to surface of the nearest points Inner Bound sphere.

Now its got simple BVH to discard rays that don’t intersect anything and to find near points.

Very crude render with 100 000 particles, 0.5 step size and 2.0 blob size renders in 25s on 6600Q @ 3.2GHz. Its suprisingly fast compared to how poor my optimizations are at this point.

If you zoom close you’ll notice artifacts (“banding”) caused by the large spep size, since it doesn’t even refine the exact hit location, just leaves it there.

http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_04.jpg

Speaking of meatballs, thats exactly what we are having tonight ! Yum

Sorry, I’ll add something about the progression :slight_smile: Looking good. Do you think you’ll add a relax parameter ?

Looking good, looking forward to this one, always looking for a good way to render water.

in that thought, stretch and squish would be nice or even speed stretch and flatten ala realflow meshing.

Stretching is possible but I think it would increase the rendertimes quite a bit. I’ll look into it once I’ve gotten the static system work and move on to dynamic (motion blur) version.

There is not relax parameter but adjust threshold value does give similar effects: http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_06.jpg

Hi Bercon,

“Did you use it also to trace intersections to find if any points were along the ray and then started marching iterativly from the first bounding box intersection forward?”
Yes, that’s exactly what I did. I first check the intersected leafs and order the intersected ones into an array in the order of their intersection. The only tricky part is to keep track of which boxes you are intersecting at each step. But this way it’s realy fast for opaque materials.
I tried both normal metaball algorithm and the zhu/bridson approach:

Best regards,

Dieter

Thanks Dieter, I have to check out that zhu/bridson approach sounds intresting.

I’ve now succesfully made the BVH optimizations for opaque blobs. Its amazingly fast. Still some major stuff missing but anyway.

10 000 000 particles. Renders in ~140 seconds with Q6600 @ 3.2Ghz. Eats roughly 150MB memory or something along those lines. The major slowdown is caused by pflow. If I’d use pointcloud from mesh it would probably be a lot faster (30 seconds or something around there). I’ll have to add mesh verties as blobs support for that.
http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_07.jpg
http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_08.jpg

Here is a test just to check everything is fine with the surface, supports GI, reflections, shadows etc.
http://www.niksula.cs.hut.fi/~jylilamm/graphics/Metaballs\_09.jpg

Wow!! Looks fantastic.