A C++ port of the Python pysph screen-space fluid rendering demo.
-
SPH Fluid Simulation - Smoothed Particle Hydrodynamics with CUDA
- Grid-based neighbor search using spatial hashing
- Thrust-accelerated sorting
- M4 (cubic spline) kernel for density estimation
- Pressure and viscosity forces
-
Screen-Space Fluid Rendering (Simon Green's technique)
- Three render modes: Points, Balls, Advanced
- Depth map with curvature flow smoothing
- Thickness map with Gaussian blur
- Final compositing with Beer's law absorption and Fresnel specular
- Windows 10/11
- Visual Studio 2019 or 2022
- CUDA 12.x (with CUDA build customizations for Visual Studio)
- vcpkg with the following packages:
freeglut:x64-windows-staticglew:x64-windows-staticimgui[freeglut-binding,opengl3-binding]:x64-windows-static
-
Install vcpkg dependencies:
cd ../vcpkg ./vcpkg install freeglut:x64-windows-static glew:x64-windows-static imgui[freeglut-binding,opengl3-binding]:x64-windows-static
-
Open
pysph-cpp.slnin Visual Studio -
Build (Release x64 recommended for performance)
pysph-cpp.exe [num_particles]
Default is 8000 particles. Start with a lower number and increase based on your GPU.
- Left mouse drag: Rotate view
- Right mouse drag: Translate view
- Mouse wheel: Zoom
- H: Toggle UI
- Space: Pause/Resume simulation
- M: Cycle render mode (Points → Balls → Advanced)
- R: Reset simulation
- ESC: Exit
- Points: Simple GL_POINTS rendering
- Balls: Point sprites rendered as lit spheres
- Advanced: Full screen-space fluid rendering with:
- Depth smoothing (curvature flow)
- Thickness-based transparency
- Beer's law color absorption (water-like blue)
- Fresnel reflections
- Smooth Depth: Enable/disable curvature flow smoothing
- Blur Thickness: Enable/disable Gaussian blur on thickness map
- Smoothing Iterations: Number of curvature flow iterations (0-100)
- Z Contribution: Adaptive smoothing factor based on depth gradient
- Original Python implementation: [pysph project]
- Screen-space rendering technique: Simon Green (NVIDIA)
- SPH theory: Matthias Müller et al.