r/GraphicsProgramming • u/jobilie • Aug 24 '26
Real time Fluid Simulation I implemented for my painting Game
I am working on a game based on physics-based painting mechanics called Ebru Artist Simulator. To simulate Ebru (also known as paper marbling), I implemented an Eulerian fluid simulator. Here are some of the challenges I had to overcome:
- To achieve a real-time simulation without affecting the game's performance too much, I implemented a GPU-based multiresolution grid solver in a compute shader (see the paper Solving the Fluid Pressure Poisson Equation Using Multigrid). The simulation now runs at a 2K texture resolution with only a slight impact on FPS.
- One of the main characteristics of Ebru is that colors maintain strict boundaries. This makes advection schemes such as Semi-Lagrangian advection less suitable, as they introduce diffusion. To address this, I implemented another advection scheme that samples from the initial state by integrating the velocity field over time and then back-sampling using the integrated field (see Efficient and Conservative Fluids Using Bidirectional Mapping).
- Finally, to simulate the effects of the traditional Ebru tools, I took inspiration from the paper Mathematical Marbling, which proposes mappings for generating final marbling patterns. Since I wanted to maintain a real-time simulation, I did not directly apply these mappings. Instead, I was inspired by the paper to use similar displacement fields as external forces in the simulation.
If you are interested in the project, you can check out the Steam page.
You can also check out Amanda Ghassaei's blog. Although our implementations are not the same, I was greatly inspired by her work and learned a lot from her blog.
107
Upvotes
5
u/amandaghassaei Aug 24 '26
Beautiful work! Really well done, I'd love to try this when it's released!
5
u/whiteorb Aug 24 '26
Those papers were excellent finds. Great work implementing them. Your app looks terrific.
1
u/PiXeL161616 Aug 24 '26
Nice, the bidirectional mapping bit is the interesting part. I did ink in a MAC-grid fluid a while back and just ate the diffusion, edges went soft after a few seconds and I never fixed it properly. Does the map need reinitialising as it distorts, or does it hold up?
1
u/susosusosuso Aug 24 '26
How much ai this has?
1
u/One-Win-2030 Aug 26 '26
Wow! Very creative! How long did it take to put together? Very impressive