Skip to content

Demonstration of a technique for rendering fluids similar to those found in the video game ‘Portal 2’. Written in C++ with OpenGL 3.3

Notifications You must be signed in to change notification settings

DoerriesT/Implicit-Surface-Fluid-Rendering

Repository files navigation

Implicit Surface Fluid Rendering (Portal Fluid)

PortalFluid

This is a demonstration of an effect for rendering fluids with implicit surfaces (similar to those found in the video game ‘Portal 2’), written in C++ and OpenGL.

Controls

  • Right click + mouse rotates the camera.
  • WASD moves the camera
  • 1-3 to switch between different drawing modes (points, quads, spherical distance fields, final result)
  • F, G, H, J to switch particle simulation speed (normal, slow, fast, freeze)
  • F1-F4 to switch between different materials (water, glass, air bubbles, soap bubbles)

How does it work?

It works by first simulating particles on the CPU. PortalFluid
Then it renders a quad for each particle on the GPU. PortalFluid
And finally it traces a ray in the quad’s pixel shader against the implicit surface formed by the distance field formed by the set of particles. Each particle on its own defines a spherical distance field where the implicit surface is defined as being at distance X from the surface. This results in small spheres that can look like droplets. PortalFluid
By combining the distance fields of multiple particles, a more natural result can be achieved because the implicit surface now deforms according to the influences of multiple particles. PortalFluid

Requirements

  • GPU with support for OpenGL 3.3 or better

How to build

The project comes as a Visual Studio 2017 solution and already contains all dependencies. It should be built as x64.

Credits

About

Demonstration of a technique for rendering fluids similar to those found in the video game ‘Portal 2’. Written in C++ with OpenGL 3.3

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages