Metaballs scriptinc issue

Hi im trying to reproduce that;

someone knows how can I fix that isue?

Thank you!!!

272670-error-metaballs.jpg

This is the code inside te custom node;

//////// evaluate the distance

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

float dot1 = dot( normalize(curpos-Sphere1.xyz), float3(0.707,0.707,0) )-1;

float dot2 = sin( dot12 + (t2) ) * 1.5;
dot2 += sin( dot124 + (t8) ) * 0.07;
s1 -= dot2;

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

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

return curdf;