Particle-based fluid simulations are very popular in computer graphics. For coolant flow, engine analysis, blood flow, and interactive applications, particle-based simulation methods are often preferred over grid-based ones, as they compute fast and offer a number of advantages such as well-defined fluid volume and the flexibility to model interaction with rigid surfaces.  With the advances in graphics hardware, large-scale fluid simulations can be achieved in real-time; however, rendering fluid volume from such simulations is not computationally trivial. Approaches based on ray tracing can render fluids with very high quality but they require a significant amount of computation, thereby restricting their use in real-time fluid simulation and rendering pipelines. Rasterization-based approaches, on the other hand, can mitigate the need for heavy computation but do not offer a way to realistically render fluid volume. For high-performance rendering, most rasterization-based methods opt to display the fluid as a collection of small spheres using an imposter or sprite-based approach (Figure 1).

Screen-Space Fluid Rendering in VTK

Kitware has been working in the area of particle-based simulation, specifically Smoothed Particle Hydrodynamics (SPH), for some time. Recently we’ve added SPH-based fluid simulation methods to our Medical Simulation Toolkit-iMSTK [1] and implemented particle-based, fluid rendering techniques in VTK [2, 3]. This work adds a new feature to VTK to render fluids in real-time given the particle data using screen-space rendering techniques.

Figure 1. Fluid simulation visualized using VTK’s spherical glyphs in iMSTK.

Currently, VTK offers vtkOpenGLSphereMapper that supports visualizing particle data as sphere glyphs. In order to achieve realistic fluid rendering in real-time, we introduce vtkOpenGLFluidMapper—a new mapper class that implements an efficient screen-space pipeline for rendering large-scale fluid simulations. Our new mapper can render more than 10 million particles in real-time with superior quality.

We implement our fluid mapper using the popular screen-space fluid rendering pipeline introduced by Van der Laan et al. [4]. The pipeline consists of several render passes as depicted in Figure 2. First, the particles are rendered as spheres into a depth buffer with depth test enabled. The depth buffer thus contains a bumpy surface that represents the surface of the fluid. In the second pass, we again render the particles as spheres into a thickness buffer. For this pass, the depth test is disabled while blending is enabled to accumulate the spheres’ thickness. This render pass can also be performed one more time to accumulate particle colors if present.

Note that all the buffers obtained so far are very noisy since they are rendered from spheres that represent discrete particles. Therefore the depth and thickness buffers are filtered before storing them into normal and filtered thickness buffers, respectively. This results in smooth rendering of the fluid volume. Finally, a composition pass is performed to combine all the necessary buffers into a final rendering result. 

Figure 2. Overview of the rendering pipeline in the vtkOpenGLFluidMapper.

We filter the thickness and color buffers using a high-performance, separable  Gaussian filter (i.e., 1-D Gaussian filters in each dimension). Filtering the depth buffer is more complex and requires much care. In particular, distinct surfaces that are close to each other in the texture coordinates but have different depths should not be blended together. On the other hand, different parts of the same surface that have different depths due to viewing from a grazing angle should be smoothed out to avoid discontinuity. Our vtkOpenGLFluidMapper provides two filtering options for smoothing the depth surface: Bilateral Gaussian Filter and Narrow-Range Filter (default) [5]. While the Bilateral Gaussian filter is simpler and requires less computation, it produces lower surface quality as compared to the Narrow-Range Filter, as shown in Figure 3.

Figure 3. Surfaces smoothed by Bilateral Gaussian Filter (left) and by Narrow-Range Filter (right) and their corresponding close-up views.


Table 1 shows a rendering benchmark with an increasing number of particles in the dataset. All the tests were run on an Intel Core i7-8700K machine with 32GB RAM and NVIDIA 1080Ti GPU. The render window has a resolution of 1920×1080 pixels and the viewport is displayed as shown in the video above. The render time reported averages over 1000 frames.  For more accurate timing, we explicitly synchronize the GPU by calling glFinish before and after all render calls.

Table 1. Render time (in milliseconds) recorded with the dataset of different sizes.


Using the fluid mapper is very straightforward and similar to any other mapper in VTK. It takes vtkPolyData as input and includes support for scalar colors and scalar visibility. We, therefore, refer the user to explore the fluid mapper in the test example. There are a number of options for the different stages of the pipeline to customize the look of the fluid rendering. Some of the key parameters and their meanings are described in Table 2.

Table 2. Some key parameters in vtkOpenGLFluidMapper to customize the rendering output.

The videos above demonstrate the results of fluid rendering using our fluid mapper, one with uniform color and one with particle colors. There are approximately 675K particles in the scene. Note that the dragon is given as a static object which does not interact with the fluid. The rendering pipeline automatically discards all the fluid pixels that are occluded by the dragon during the depth test.


Although the new fluid mapper can render a large dataset of fluid simulation in real-time with good quality, it still suffers from some disadvantages typical to screen-space rendering techniques. One such limitation is the non-physical computation of refraction and reflection since they are achieved by approximately sampling the environment texture instead of computed from actual geometries using physically-based ray tracing. Furthermore, the rendering can show artifacts in the form of discontinuous or noisy surfaces when looking from grazing angles, and popping artifacts when the camera is in motion. Those artifacts are due to the lack of spatial information in the depth buffer and can be reduced by setting the right filter parameters. For large scale simulations where the particle radius is very small, such artifacts may be insignificant.

Future Work

Screen-space fluid rendering offers great advantages for rendering a large amount of fluid simulation data at interactive frame rates. In the future, we will enhance the rendering quality by employing a more accurate refraction model that accounts for multiple refractions [6] and use screen-space ray tracing techniques [7] that can enhance the realism of reflection and refraction.

With the recent introduction of real-time ray tracing on GeForce RTX cards recently, high-quality rendering of complex scenes can be achieved in real-time. Since ray-tracing produces physically accurate (and hence visually realistic) results, there is a considerable impetus in the graphics community towards these techniques whose usage is expected to increase considerably over time. The recent release of VTK version 9.0 fully supports hardware-accelerated ray tracing using OptiX. In the near future, the rendering pipeline in our fluid mapper can be improved by incorporating RTX (fully or partially) to achieve much higher rendering quality while still maintaining superior performance for extremely large-scale fluid simulations.


  4. Wladimir J. van der Laan, Simon Green, and Miguel Sainz. 2009. Screen space fluid rendering with curvature flow. In Proceedings of the 2009 symposium on Interactive 3D graphics and games (I3D ’09). ACM, New York, NY, USA, 91-98.
  5. Nghia Truong and Cem Yuksel. 2018. A Narrow-Range Filter for Screen-Space Fluid Rendering. Proc. ACM Comput. Graph. Interact. Tech. 1, 1, Article 17 (July 2018).
  6. Takuya Imai, Yoshihiro Kanamori, and Jun Mitani. 2016. Real-time screen-space liquid rendering with complex refractions. Comput. Animat. Virtual Worlds 27, 3-4 (May 2016), 425-434. 
  7. Morgan McGuire and Michael Mara, Efficient GPU Screen-Space Ray Tracing, Journal of Computer Graphics Techniques (JCGT), vol. 3, no. 4, 73-85, 2014.

2 comments to Screen-Space Fluid Rendering in VTK

Leave a Reply