Search Unity

Physics FluXY, eulerian GPU fluid simulator

Discussion in 'Tools In Progress' started by arkano22, Aug 4, 2021.

  1. arkano22


    Sep 20, 2012
    Hi there,

    I've been working on and off on a multipurpose 2.5D fluid simulator. It allows you to simulate fire, ink, oil, fog, mud, and magic-like VFX stuff. It's cheap enough to be used liberally in a project.

    Simulation is performed in a 2D plane, that can optionally face the camera. Objects in the scene are projected to the plane and can affect fluid density/velocity, 3D forces/accelerations are converted to a 2D representation. This makes the fluid look 3D-ish, though it's only 2D.

    It all works on regular vertex/fragment shaders, shader model 3.0. No compute buffer support required. Works in Unity 2019.3 and up. For now it only supports the built-in render pipeline, though URP support will be there by launch.

    • Advection, buoyancy, viscosity, turbulence and dissipation.
    • Rectangular fluid containers with periodic, solid or open boundary conditions at the edges.
    • 3D external forces/accelerations are converted to 2D space.
    • Objects can be projected onto the simulation container and affect fluid velocity and/or density.
    • Inertial forces.
    • Multicolored fluids (eg you can mix red, green and pink fluid in a single simulation).
    • Parallel solving of up to 16 different containers. This reduces the amount of CPU work to a minimum, as single Blit() can update all 16 containers at once.
    • LOD. Distant containers use lower-resolution buffers. A single memory pool can be shared by multiple containers, and their sizes adjusted depending on their relative level of detail to ensure constant memory usage.
    • Different resolution for velocity and density buffers.
    • Pressure projection uses a fast separable poisson filter (derived for 30 jacobi iterations). See:
    • One way coupling with rigidbodies: the fluid can move rigidbodies around.

    Thoughts, feedback? what would you use this for?

    kind regards,
    Last edited: Aug 4, 2021
    sjm-tech, knxrb, Ruchir and 1 other person like this.