Metaballs Blobbing Effect (Fluid Sim)


Does anyone know how I can tackle the issue of having meshes merge/fuse into one shape where the gaps are filled in by Geo.

Similar to how they achieve the oil in Portal 2.

I’d like to know this too for a project :slight_smile:

I guess what I want is meta balls, but I would love to be able to use geo-particles.

This is what I have done so far. I followed this video as closely as I can.
[link text][1]

The custom hlsl code they use is

///////////MetaBalls Simple

float3 CamVec = normalize(WorldPos-View.ViewOrigin);
float3 curpos = WorldPos;
float3 normal = 0;

int maxsteps = 16;
float curdist, accum = 0;
float minstepsize = 0.01;

int i = 0;
while(i < maxsteps)
	curdist = CustomExpression0(Parameters, curpos, k, Sphere1, Sphere2, Sphere3, t);
	if(curdist < tresh)
		return float4(1,1,1,1);
	curpos += CamVec * max(minstepsize, curdist);
	minstepsize += 0.02;

return 0;


//////// evaluate the distance

float s1 = distance(, curpos)-Sphere1.w;
float s2 = distance(, curpos)-Sphere2.w;
float s3 = distance(, curpos)-Sphere3.w;

float dot1 = dot( normalize(, float3(0.707,0.707,0) )-1;

float dot2 = sin( dot1*2 + (t*2) ) * 1.5;
dot2 += sin( dot1*24 + (t*8) ) * 0.07;
s1 -= dot2;

float h = saturate( 0.5+0.5*(s2-s1)/k );
s2 = lerp( s2, s1, h ) - k*h*(1.0-h);

h = saturate( 0.5+0.5*(s3-s2)/k );
float curdf = lerp( s3, s2, h ) - k*h*(1.0-h);

return curdf;

I have been trouble shooting for a couple of hours now and I can’t seem to find any reason to why mine has error and the one they show of in the video works.
This is my errors.



In the metaball hlsl, change View.ViewOrigin to View.WorldViewOrigin

I found that reading the youtube comments on the livestream but I believe in the stream they mention that the safest thing is to add an input to the function for calls like that because it’s not uncommon for them to change the naming in the engine.

Hopefully you’ve solved it by now since you asked in October but if not, that’s your answer :slight_smile: