Fluid Rendering

Flex fluid particles can be rendered with a screen space technique. The surface rendering is configured using a Flex Fluid Surface asset. The fluid surface asset can then be assigned to Flex Container to render the corresponding particles with the surface technique. The look of the surface depends on:

  1. Creating a Flex Fluid Surface
  2. Fluid Surface Properties
  3. Container
  4. Emitter Settings
  5. Surface Material
_images/fluidsurface.jpg

Creating a Flex Fluid Surface

To create a fluid surface asset, right-click in the Content Browser, and choose Create Advanced Asset->Physics->FlexFluidSurface.

_images/NewFluidSurface.jpg

Fluid Surface Properties

Give your container an appropriate name, e.g.: FlexFluidSurface, and double click to open it’s property sheet.

_images/fluidsurfaceasset.jpg
  • Smoothing Radius Radius for smoothing the surface. Higher values result in a smoother surface.
  • Max Radial Samples This parameter controls how many neighboring pixels in each direction are taken into account for the screen space smoothing operation. It limits how large the smoothing filter defined through the Smoothing Radius can become in screen space. Large values can have an impact on performance.
  • Depth Edge Falloff The depth edge falloff controls smoothing across inner silhouettes. If the depth separation between particles exceeds the size of the particles, smoothing should be turned off to avoid blending between foreground and background. The depth edge falloff controls how much smoothing is tuned down based on the depth separation. A value of 0.0 disables all smoothing.
  • Depth Particle Scale The size of the emitted particles influences the distance of the rendered surface to the particles. Larger particle sizes result in a surface that makes the liquid appear to have more volume. The Depth Particle Scale controls the particle sizes influencing the shape of the surface.
  • Half Resolution Compute the fluid surface in half resolution to improve rendering performance.
  • Thickness Particle Scale Translucent surfaces look more convincing if the background becomes less visible where the liquid is thicker. The screen space surface technique provides a thickness value to the material used to render the surface to achieve such an effect. The thickness value is computed using an additive blend between the particles rendered as spheres. The size of the spheres is controlled by this parameter.
  • Material The material that is used to shade the fluid surface.
  • Cast Particle Shadows Use fluid particles to cast shadows on other objects and the fluid surface (self shadowing).
  • Shadow Particle Scale Relative scale applied to particles for shadow casting.
  • Receive Precached Shadows Controls whether the surface receives shadows from static level geometry. In the current implementation, dynamic shadows are always cast onto the surface.
  • Disable Emitter Rendering Supress native emitter particle rendering when surface is rendered.

Container

The main parameter that need to be adjusted in the Flex Container for surface rendering are shown here:

_images/FluidSurfaceContainer.jpg
  • Fluid Fluid surface rendering is only available for fluid particles. This option needs to be enabled.
  • Anisotropy Scale If this parameter is set to larger than 0.0 the Flex simulation generates per particle information that can be used to improve the fluid surface rendering. The anisotropy information is used to render oriented ellipsoids instead of spheres which makes the surface look much smoother. Setting this higher allow the ellipsoids to stretch more. A value around 1.0 works usually well. The overall particle scale can be adjusted using the emitter particle size or with the Depth Particle Scale in the Flex Fluid Surface template.
  • Anisotropy Min Defines how thin a particle can become. It makes sense to limit the thickness for example to avoid shadowing artefact which can appear for very thin objects. A value around 0.1 works usually well.
  • Anisotropy Max Defines how thick a particle can become. It can look weird if ellipsoids stretch too much as the geometric shape can be become very obvious. A value around 1.0 works usually well.
  • Position Smoothing The look of the surface can be improved further by enabling smoothing of the particle positions. Values larger than 0.0 enable the particle smoothing.
  • Fluid Surface The Flex Fluid Surface asset used to render the fluid particles for this Flex Container.

Additionally it might be useful to adjust the Rest Distance of the Flex Container to achieve more visual surface details. The Collision Distance can be used to reduce the visual gap between the particle surface and the level geometry.

Emitter Settings

The surface rendering is largely independent of the particle system and emitter settings. There are two particle properties that are specified by the emitter:

  • Particle Scale The X component of the size is used for the surface appearance.
  • Particle Color Available in the material editor through the FlexFluidSurface Color material expression.

To make a Flex Particle Emitter work with surface rendering make sure to select the Fluid option in Flex Phase properties.

Surface Material

The material referenced in the Flex Fluid Surface asset is used to shade the surface. The surface rendering only supports a restricted material feature set. The Flex Project contains example materials that can be used as a reference.

  • Material Blend Mode: should either be set to Translucent or Masked.
  • FlexFluidSurface Thickness material expression can be used to read the thickness of the liquid volume at a given screen location.
  • FlexFluidSurface Color material expression can be used to read the particle colors specified by the emitter.
_images/FluidSurfaceMaterial.jpg