Jump to content

2D Curve metaball


odforce123

Recommended Posts

Hey, 

 

I'm looking for a way to create a setup that behaves like metaball but on curves, so basically my idea is to create a setup like in the reference images, where I scatter random points and copy circle shapes to points that have a pscale set based on the distance to a closest point to avoid intersection, and these circles are somehow combined with a distort form between them, like in metaball. I am very curious how you would approach something like this and thank you in advance for any advice!

 

In the attachment I'm sharing the images I found in simillar setup but done in Rhino.

 

ddc05b8c3d3e9dfff6af9f210029fdf00efe2706_2_690x449.png

5f725a527bbd4c575b17012edadde2cd159c21f2_2_582x500.jpg

97214b5e3de64d8889ca08af78859aff2aeb361c.png

Link to comment
Share on other sites

How to feed into this Code pscale for points  from 2 input ?
 

int pntcnt = npoints(1);
float accum = 0;
for(int i=0; i<pntcnt; i++)

{
    vector tarpos = point(1, "P", i);
    float dist = distance(tarpos, @P);
    float falloff = fit(dist, ch('start') , ch('end') , 1,0);
    accum = max(falloff,accum) ;
   
    }

@Cd = set(accum, 0, accum/4);

 

Link to comment
Share on other sites

Hi Tomek,

you could use smooth minimum functions: https://www.shadertoy.com/view/DlVcW1
Article: https://iquilezles.org/articles/smin/


Here is an example for Houdini:

float r = chf('radius');

function float smin(float a, b, k){
    k *= 1.0/(1.0 - sqrt(0.5));
    return max(k, min(a,b)) - length(max(k - set(a,b), 0.0));
}

float dists[];
int pts[] = pcfind_radius(1, 'P', 'pscale', 1.0, v@P, 10.0, 2, dists);

float d = smin(dists[0], dists[1], r);

f@dist = d;

image.png.be7220ee0d7a1180e543c39a96fb0cb6.png
 

metaball_2D.hipnc

Edited by konstantin magnus
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...