Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Calculating and Reproducing Volumes
#1
I am working on a bartending simulator in VR, and my current goal is to allow players to capture fluids in glasses as well as pour them out. I've decided to represent liquid volumes within containers with a shader, so I count and remove fluid particles when they enter the glass. When the user tilts the glass far enough, I emit new fluid particles to represent the contained liquid emptying from the edge of the glass until the glass is "empty."

I'm having issues producing consistent results. I know that emitters aren't designed to produce specific numbers of particles, which is fine, but controlling the rate via time doesn't seem to be producing the amount of volume I expect. I'm hoping to remove and recreate the same volume of fluid with 95% or more accuracy.



So, a two part problem:

  1. Is there an easy way to calculate the volume of a fluid when its particles interact with a collider?
  2. Can a known volume of fluid be reliably created when controlling an emitter's rate/duration/shape?



Thank you for your time! Obi Fluid has been incredibly fun to work with, and I'm excited to learn more about its inner workings.
Reply
#2
(14-11-2024, 05:11 PM)ZacharyP Wrote: Is there an easy way to calculate the volume of a fluid when its particles interact with a collider?

Hi!

Just multiply the amount of particles in contact with the collider by the individual volume of each one. Particles are assumed to be spheres during simulation, so you can use the usual formula for the volume of a sphere: 4/3 * PI * R^3.

(14-11-2024, 05:11 PM)ZacharyP Wrote: Can a known volume of fluid be reliably created when controlling an emitter's rate/duration/shape?

The volume of fluid emitted depends on the amount of particles emitted and the volume of each particle, so again this is just a matter of counting particles and adding up their volume.

You can query the amount of active particles in the emitter and multiply that with the volume of each one, then set the emission speed to zero once you're over the target volume. Note this will likely leave you slightly over the target volume since you're reacting to the volume of fluid already emitted. You could also calculate the amount of fluid that's about to be emitted, but that's considerably more mathy. Let me know if you need help with this.

It's worth noting that fluids in Obi -and most fluid simulators- are not perfectly incompressible. Unless a lot of time is spent on the simulation, fluids are slightly compressible, which means their actual volume might be less than its rest volume. This is specially noticeable with deep containers, as the pressure at the bottom of a fluid body increases with depth. Spending less time solving density constraints (in Obi, using less substeps/density constraint iterations) will result in more compressible fluid. Conversely, spending more time (more substeps/iterations) will result in less compressible fluid.

(14-11-2024, 05:11 PM)ZacharyP Wrote: Thank you for your time! Obi Fluid has been incredibly fun to work with, and I'm excited to learn more about its inner workings.

Glad to hear! thank you for your kind words Sonrisa

kind regards
Reply