Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Fluid Particles interaction Script
#2
(19-11-2020, 12:40 PM)JoseCarlosĀ S Wrote: Hi, im developing a game, and i would like to implement an interaction between to fluids (fluid A and fluid B, the particles destroy each other when in contact). I saw a thread that said fluid particles cant detect collision directly, they have to detect it by vorticity or temperature... How do you set it up so that each particle has differnt temperature? And how would a script that destroys them "onCollision" look like?

Thank you.

Hi there,

I think you're mixing up concepts here.

Fluid particles interact with each other using a kernel or support function. A kernel is basically an area around each particle, where density (amount of particles per volume unit) is measured. If there are too many particles within the kernel, which means local density is too high, a repulsion force (pressure) is applied to all particles around the center particle in order to decrease density. If there are too few particles, an attractive force is applied to increase local density. That's how fluid maintains constant density, which is what makes fluid behave like fluid.

Because of this, particles do not collide with each other, because they're not solid. They interact via constraining density within each kernel.

Vorticity and temperature have nothing to do with this. Vorticity measures how "swirly" the fluid is at a point, and temperature measures well, temperature. They play no part in particle interaction whatsoever.

Since you can't access particle kernels directly, you will need a way to know if a particle has neighbors that belong to a different type of fluid. You can use the diffusion data channels for this. Each fluid blueprint has 4 channels of diffusion data that you can give any meaning to. These values will be averaged between particles inside a kernel, so if you give fluid A a diffusion value of (1,0,0,0) and fluid B a value of (0,0,0,0), at runtime you know that any particle with a value other than these (for instance, 0.5,0,0,0) it must be destroyed because it has been within the kernel of particle of the opposite type.

You can check the FluidMixing or Raclette sample scenes for some examples on how you can use the diffusion channels. In FluidMixing, the diffusion channels are used to drive a color gradient. In Raclette, they're used to drive fluid viscosity and color.

I hope this makes sense, fluid simulation is quite complex and can have a steep learning curve at the start.
Reply


Messages In This Thread
RE: Fluid Particles interaction Script - by josemendez - 19-11-2020, 12:50 PM