Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Is there a way to kill fluid particles on contact with a different fluid?
#2
(04-05-2022, 09:45 AM)locque Wrote: I would like to have one fluid dissolve almost immediately after coming in contact with a different fluid rather than the two of them mixing, ideally with a short delay of around 0.5-1 second so it looks a bit more like they're mixing rather than the particles being killed.

Is this possible? I suppose this would require creating a script that talks to individual particles, which are probably not exposed by the backend.

Fluid particles don't collide with other fluid particles. They interact with each other trough density constraints., so there's no way to know when two fluid particles contact each other, it's not an instantaneous event unlike collision constraints.

Internally, density constraints are stored using a grid structure that's not exposed trough the API. Even if it was, the only way to access it efficiently would be using jobs since the neighborhood of each particle can be rather large.

(04-05-2022, 09:45 AM)locque Wrote: If it's not possible, any ideas on how to achieve a similar effect? The scenario is mixing a small amount of very high resolution fluid into a large volume of low resolution fluid. The highres fluid is taken from a bottle with a dropper that has an emitter and added to the pool of lowres fluid, which needs to have basically no effect on the volume of that lowres fluid.

You could simply delete fluid particles whose userData has reached a given threshold. For instance, if your high-fluid particles carry a userData value of (1,0,0,0) and the low-res carries (0,0,0,0), once they're completely mixed both would have a value of (0.5,0,0,0). You could detect fully "dissolved" high-res particles by checking their userData and then kill them.

Another option: Since the high-res fluid shouldn't affect the volume of the low-res fluid, maybe this could be done using advection? You can use solver.implementation.InterpolateDiffuseProperties() to get interpolated fluid properties at any position. See ParticleAdvector.cs for a use case that uses interpolated fluid velocities to drive regular Unity particle system (this is how foam is done in the FluidFoam sample scene).

If you want to pass properties from the advected particles back to the fluid (such as color), you'd need to modify the source code of InterpolateDiffuseProperties() for the Burst backend, to allow writing data the other way around (advected particles->fluid particles).

kind regards,
Reply


Messages In This Thread
RE: Is there a way to kill fluid particles on contact with a different fluid? - by josemendez - 04-05-2022, 10:01 AM