Jump to content
bentway23

Gentle nudge/push particles away from surface (using SDF?)

Recommended Posts

Alrighy, I have a big wedge of stupid in my head that is keeping me from doing this. I have particles emitting into a container (a super-simplified version is attached). I would like to get it where instead of the usual bounce/slide off a wall, the particles slow down and gradually move/are pushed away from the containing walls. I'm assuming this would be done using SDF/volume sample/volume gradient and a POP wrangle modifying the velocity based on the sampled values, but I just can't get it to work. I've seen lots of tutorials on using this approach to get particles to stay NEAR a surface, but my brain isn't adapting that to a nudge-away-from-a-surface instead of a nudge-towards. What am I doing wrong?

The POP wrangle code-in-progress (the collider is input 2, the VDB is input 3):

float samp = volumesample(2, 0, @P);
vector grad = volumegradient(2, 0, @P);

@v *= -grad;


SOMETHING is happening, just not what I want. (And ideally I could have a second SDF inside the container pushing out, thus gently keeping the particles within a certain radius of the container wall, not going to the center.)

Thanks for any help!

 

example.hiplc

Edited by bentway23

Share this post


Link to post
Share on other sites

Hi,
I attached an example. I think that technically, you are doing it right. Maybe try to add just a little bit of that gradient?

v@v -= grad * 0.01;


If you want to use the samp, then the wrangle might look like this:

float samp = volumesample(2, 0, @P);
vector grad = volumegradient(2, 0, @P);

float omin = chf("old_min"); // 0 in -1 to 0
float omax = chf("old_max"); // 0 in -1 to 0
float nmin = 0;
float nmax = 1;
samp = fit(samp, omin, omax, nmin, nmax);
samp = chramp("dist",samp);

v@v -= normalize(grad) * samp * 0.01;

 

Also you may toggle the Fill Interior on the VDB from Polygons.

image.thumb.png.0e1b2ab959b81fc43ef25f494622528c.png

Btw this is great tutorial, you may jump to 36th minute, or so:
https://vimeo.com/162213251

 

example.hiplc

Share this post


Link to post
Share on other sites

Btw in that example, I also added a VDB Visualize Tree - Points with values. With that node, you can see, what are the values of SDF inside your Container.

In your example, the minimum SDF value inside the container is -0.495, so "old min" should be set to -0.5.

The fit() functions remaps samp for the ramp (because ramp wants the values to be 0-1).

(You could also proceduralize that "old min" with Attibute Promote set to Minimum ... if you want to, let me know)

  

image.thumb.png.ce83389d47ead51883823ba3b64173f2.png

Share this post


Link to post
Share on other sites

This is great! I'm glad to see I was at least in the ballpark, and I was able to quickly create and inner "core" pushing them away from the center and taming that unruly mob by simply adding instead of subtracting the inner gradient. Also, the visualize tree is new to me and way better than the create-a-bunch-of-points-create-an-attribute-and-scroll-through-the-geometry-spreadsheet method I've been using.

 

Also, I wasn't sure about "fill interior"--my approach was (theoretically) making a hollow VDB from the container walls and using the external-to-the-vdb-but-inside-the-container values for the sampling.

 

Thanks so much!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×