PBD Fluid

Shuang Yu - Computer Animation Final Project

For my final project, I implemented the position-based fluid method and used SDF for collision detection.

Density = 50

Method

Position Based Fluid

The position based fluid has the similar structure of cloth PBD in A5.

  1. Apply Force
𝑣𝑖=𝑣𝑖+βˆ†π‘‘π‘“(π‘₯𝑖)π‘₯𝑖=π‘₯𝑖+βˆ†t𝑣𝑖𝑣_𝑖=𝑣_𝑖+βˆ†π‘‘π‘“(π‘₯_𝑖) \\ π‘₯_𝑖=π‘₯_𝑖+βˆ†t𝑣_𝑖
  1. Position-based density constraints
𝐢𝑖(𝑝1,……𝑝𝑛)=πœŒπ‘–/𝜌0βˆ’1πœ†π‘–=βˆ’πΆπ‘–(𝑝1,…𝑝𝑛)βˆ‘π‘˜βˆ£βˆ‡(π‘π‘˜)πΆπ‘–βˆ£2𝑝(𝑖)+=1𝜌0βˆ‘π‘—(πœ†π‘–+πœ†π‘—+π‘ π‘π‘œπ‘Ÿπ‘Ÿ)βˆ‡π‘Š(π‘π‘–βˆ’π‘π‘—,h)𝐢_𝑖 (𝑝_1,……𝑝_𝑛 )=𝜌_𝑖/𝜌_0 βˆ’1\\ πœ†_𝑖=βˆ’\frac{𝐢_𝑖 (𝑝_1,…𝑝_𝑛 )}{βˆ‘_π‘˜|βˆ‡_(𝑝_π‘˜ ) 𝐢_𝑖 |^2} \\ 𝑝_(𝑖 )+= \frac{1}{𝜌_0} βˆ‘_𝑗(πœ†_𝑖+πœ†_𝑗+𝑠_π‘π‘œπ‘Ÿπ‘Ÿ )βˆ‡π‘Š(𝑝_π‘–βˆ’π‘_𝑗,β„Ž)
  1. Collision Detection and Response(SDF)
  1. Vorticity Confinement and Viscosity
𝑣(𝑖)+=π‘βˆ‘π‘—vπ‘–π‘—βˆ‡π‘Š(π‘π‘–βˆ’π‘π‘—,h)𝑓𝑖+=ℇ(𝑁×𝑀𝑖)𝑣_(𝑖 )+=π‘βˆ‘_𝑗 v_{𝑖𝑗} βˆ‡π‘Š(𝑝_π‘–βˆ’π‘_𝑗,β„Ž) \\ 𝑓_𝑖 +=ℇ(𝑁 ×𝑀_𝑖)

Note: In the implementation of Fluid PBD, we need to find the neighbors of the particle, here I just use the brute force method.

πŸ’‘
Result with different density

density = 100
density = 20

Signed Distance Field

Signed distance field can provide the distance between a given point and a triangle mesh. We can get a signed distance. Assuming triangle normals point outwards from the enclosed volume, the sign of the distance will be positive outside and negative inside. I used a existing C++ library for the signed distance calculation.


With SDF, we can load lots of complicated object instead of simple sphere in our scene. Here I load a little prince and changed some parameter to simulate the crystal ball

(I used 1.5k particles to simulate but only render some of them in the result)

Reference

https://github.com/InteractiveComputerGraphics/TriangleMeshDistance?tab=readme-ov-file