The technique is described in that thread, however, I apply it to 3D:
-Create a plethora of billboards with a texture that represents the metaball's charge.
-Render all the billboards using additive blending to a render target.
-Combine said render target to the scene using a shader. The shader checks if the metaballs charge is > than the threshold - if so, it is rendered. (I actually cheat and use saturate(Charge - Threshold) / (1.0f - Threshold) to smooth it out instead.)
-Color the metaballs.
In the demo I provided, it's slowed down significantly by physics, but the technique is very fast, and is basically dependent on your fill rate. However, your metaballs may appear different depending on camera angle.
If someone has the performance to spare, I'd imagine that a really good looking water simulation could be made out of this and a low threshold. Also, someone far more intelligent than me can probably figure out how to extract world-space normals from the billboards, allowing for cubemap reflections and a million other fancy effects.
Tell me what you think!
Image-Space 3D Metaballs
#1 Members - Reputation: 100
Posted 09 March 2010 - 10:43 AM
The technique is described in that thread, however, I apply it to 3D:
-Create a plethora of billboards with a texture that represents the metaball's charge.
-Render all the billboards using additive blending to a render target.
-Combine said render target to the scene using a shader. The shader checks if the metaballs charge is > than the threshold - if so, it is rendered. (I actually cheat and use saturate(Charge - Threshold) / (1.0f - Threshold) to smooth it out instead.)
-Color the metaballs.
In the demo I provided, it's slowed down significantly by physics, but the technique is very fast, and is basically dependent on your fill rate. However, your metaballs may appear different depending on camera angle.
If someone has the performance to spare, I'd imagine that a really good looking water simulation could be made out of this and a low threshold. Also, someone far more intelligent than me can probably figure out how to extract world-space normals from the billboards, allowing for cubemap reflections and a million other fancy effects.
Tell me what you think!
#2 Moderators - Reputation: 5643
Posted 09 March 2010 - 11:54 AM
float dist = length(xyPos);
float weight = CalcGaussianWeight(dist);
xyPos *= weight;
return float4(xyPos, 0, weight);
Then in your final pass where you sample the summed weights, you can calculate a normal like this:
float3 normal = normalize(float3(sample.x/sample.w,
sample.y/sample.w,
max(sample.w - 0.08f, 0)));
Of course you may need to negate your Z depending on your coordinate system.
This is a screen from a little demo I made with this technique a while back:

#4 Members - Reputation: 124
Posted 09 March 2010 - 11:22 PM
I will give this a try for sure!
edit:
anyways I am curious what happens if you move the camera? does that look weird?
#5 Members - Reputation: 100
Posted 09 March 2010 - 11:41 PM
Quote: Original post by mokaschitta
this is awesome! I currently used raycasting combined with spatial hashing on the GPU to make realtime 3D metaballs but this is so much simpler :)
I will give this a try for sure!
edit:
anyways I am curious what happens if you move the camera? does that look weird?
Thanks! No, not like you'd expect from a billboard method - that's what makes it pretty neat.
Updated the demo, WASD to see for yourself:
http://astraios.net/test/Meta.zip
I'd share the source, but I'm using 3D middleware and it's horribly organized. If someone REALLY wants it, just ask.
PS: Try changing the Drop.png texture to any other grayscale picture.
edit: fixed to new link, source included
Edited by Akitsune, 05 March 2012 - 01:50 PM.
#6 Members - Reputation: 124
Posted 10 March 2010 - 05:00 AM
I am on a mac, so I cant test your demo. Anyways I thought about the method a little more and correct me if I am wrong:
this method interprets all metaballs having the same z value right? I could move one metaball in front of all the others.
An also no matter how far away a metaball is, it will contribute to the current pixel due to the additive blending.
Did you solve that anyhow or is that a limitation you have to take when using this method?
#7 Members - Reputation: 100
Posted 10 March 2010 - 10:29 AM
Correct - metaballs contribute from any distance. This is a limitation, but it isn't a huge one and is barely noticeable - this is what the threshold and billboard size should be adjusted to minimize artifacts. I'm working on adding depth so I can retrieve the world position from the metaballs and eventually use triplanar texturing which like likely have artifacts due to this.
#9 Members - Reputation: 136
Posted 10 March 2010 - 09:55 PM
I'm sorry but these are not metaballs neither an approximation of them except in a 2D case. However it's a fun technique for some kind of blotches on the screen. Just don't call them meta balls. They are far from it.
Cheers,
Pablo
www.sciencevisuals.com







