From Boxes to photorealistic Fluid (marching-cubes + raytracing) @ProjectPhysX
From Boxes to photorealistic Fluid (marching-cubes + raytracing)  @ProjectPhysX
Uploaded January 2022 | Updated September 2026, 1 week ago
From Boxes to photorealistic Fluid - how does ot work?

The fluid simulation is done with the lattice Boltzmann method (LBM) with the Volume-of-Fluid (VoF) extension and piecewise linear interface construction (PLIC) for surface tension.
VoF-LBM: researchgate.net/publication/349552856_High_Performance_Free_Surface_LBM_on_GPUs
PLIC: mdpi.com/2079-3197/10/2/21

VoF-LBM provides a 3D grid with fluid fill levels, used as isovalues for marching-cubes, which generates a contiguous triangle mesh representing the water surface.
Marching-cubes: paulbourke.net/geometry/polygonise

With raytracing I shoot light rays from the camera through the 3D isogrid. For each grid cell that a ray traverses, I run marching-cubes to generate the triangles on-the-fly, then check for ray-triangle intersections with any of these triangles. If the ray intersects, I don't use the flat-face-surface nromal of the triangle, as this would lead to visual artefacts on the reflected/refracted rays. Instead, I interpolate the surface normal at the intersection point in order to have a smoothly appearing surface. How does surface normal interpolation work with marching-cubes? I get the normals directly at the lattice points with gradient (central derivative) on the isogrid, then linearly interpolate to get the normals at triangle vertices and linearly interpolate again to where the ray intersects the triangle with Barycentric coordinates on the triangle.
The 3D lattice that the LBM provides already is one of the ideal acceleration structures for raytracing. Any ray only has to check for possible intersections with iso-surface triangles contained within the traversed grid cells. This makes it - when the lattice is not too large - even run in real time on non-RTX GPU​s.

New video with surface normal interpolation: youtu.be/UUYrWUpPQwY
Old video without surface normal interpolation: youtu.be/9Rfu9ZqW894

The simulation setup you see here is a physically accurate 4mm diameter terminal velocity raindrop impact in water, although at rather low 256x256x218 resolution for this real time demo.
See my published research paper in Microplastics and Nanoplastics, where the simulation is validated to great extent:
microplastics.springeropen.com/articles/10.1186/s43591-021-00018-8

This simulation as well as the raytracing graphics are running in real time on a single Nvidia Titan Xp GPU.

The simulation software used is FluidX3D, an OpenCL implementation of the lattice Boltzmann method. FluidX3D runs at peak hardware efficiency on the worlds fastest data-center GPUs (8799/5232 MLUPs/s on the Nvidia A100/V100 @ D3Q19 SRT FP32), on gaming GPUs and CPUs and it even runs my smartphone.
For more performance details, see: arxiv.org/pdf/2112.08926.pdf

#FluidX3D #OpenCL #Raytracing #GPU #LBM
From Boxes to photorealistic Fluid (marching-cubes + raytracing)How aerodynamic is Boeing 767-400ER? (return from SC24, landing in Munich)Formula 1 Ferrari SF71H in FluidX3D CFD at 10 Billion Cells with Wheel Rotation - 71TB CFD DataFluidX3D v2.7 Update: New Slice and Surface Pressure Data Visualization ModesSmallest CRT monitor in the world with a Raspberry PiAirodynamics of an arm chair on 4x A100 GPUsOpenCL GPU Programming for HPC Applications (ChEESE Webinar - Center of Excellence in Solid Earth)USS Enterprise CFD simulation on my gaming PCPhysX3D - 3D Barnes-Hut Tree and Galaxy Cluster SimulationHow aerodynamic is Stanford bunny?Real time CFD simulation in console (Nvidia A100)PhysX3D [GRAVITY SIMULATION] short galaxy demo
Dr. Moritz Lehmann |

From Boxes to photorealistic Fluid (marching-cubes + raytracing)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER