Fluid Rendering
Fluid Body Passes
Fluid Stream
Summary:
This work showcases some fluid rendering I did for an open-world game. Each fluid body needed to support the following features:
Placement at various elevations
Swimmable and divable
Contain partially submerged objects
Distinct visual properties
Solution:
I created three custom shaders to execute the desired effect.
Fluid Volume Shader
This shader renders its effects within a cuboid primitive, acting as a volume shader. This technique solves partially submerged object rendering and enables unique material property definitions for different fluid bodies. It executes in two passes:Caustics
This pass mimics light refracting through the fluid onto objects submerged below. The effect supports controls to fade in and out of the volume for light dissipation at depth, chromatic aberration, speed, and tiling controls.Atmospheric Perspective
This pass helps shroud objects at a distance and represents particulate density blocking light. The effect supports controls for horizontal and vertical visibility controls and color controls.
Fluid Surface Shader
This shader renders on a tessellated plane with Gerstner motion controls that animate in the vertex shader. The fluid surface uses a depth map for distinguishing shallow water regions and coastal foam and an opaque texture from the camera for refraction effects. The effect supports fragment shader controls for shallow and deep fluid colors, foam width and color, normal map intensity, tiling and speed, refraction intensity, transparency controls, and simple smoothness and metalness.Fluid Stream Shader
This shader renders on an extruded mesh from a spline, with perturbation controls that animate in the vertex shader. This shader also uses the depth map and the opaque texture for soft intersections and refractions. The streams have in and out colors that can connect different bodies of water seamlessly. The effect supports fragment controls for normal map intensity, tiling and animation, layers of animated foam, refraction intensity, transparency controls for fading in and out, and simple smoothness and metalness.