Splines

Splines are useful tools for authoring. They can give a more convenient workflow than using primitive meshes as they are malleable in the editor. Furthermore, splines are imbued with data like velocity and direction for waterflow.

A common use of splines is to set the water level to follow a riverbed using the Level Input component. A spline may also be used to add waves or flow velocity. Another typical use case of splines is to add waves aligned to shorelines.

Usage

Firstly add a Spline component to an empty game object. Then use the controls on the spline to add spline points – similar controls are also available on the spline points themselves.

To get started:

  • Add a Spline component

  • Use the spline controls on the spline to add two spline points

You will notice no spline mesh has been generated. This is becauses splines do nothing by themselves and are are used in conjunction with Lod Inputs and Shape components.

The following components can be used with splines:

  • Level Input can be used to set the water level to match the spline.

  • Flow Input can be used to make the water move along the spline.

  • Foam Input can be used to generate foam at specific spline points.

  • Shape FFT/Gerster can be used to generate waves that propagate along the river.

Relevant data components will automatically be added to spline points. For example if the spline is used with a Flow Input component, the Spline Point Data Flow component will be added to spline points which can then be used to configure the flow speed.

Lakes

Splines can be used to create lakes by adjusting the radius on each spline point.

Example

The Lakes sample contains an example of a river connecting two lakes.

Rivers

Splines can be used to create rivers and it is one of its strengths as when used with a Flow Input water will flow in the direction of the spline.

Example

The Lakes sample contains an example of a river connecting two lakes.

Shoreline Waves

Waves can be directed to be orthogonal to a spline to simulate shoreline waves by changing the Wave Direction Heading Angle. This works well with Shape Gerstner when Reverse Wave Weight is set to zero.

Troubleshooting

There is staircasing and/or small bumps on the water surface

This is due to lack of precision. Set Water Renderer ‣ Simulations ‣ Animated Waves ‣ Texture Format Mode to Precision, and set Water Renderer ‣ Simulations ‣ Water Level ‣ Texture Format Mode to Automatic.

If the problem persists, and you are targetting a mobile platform, then enable Project Settings ‣ Crest ‣ Full Precision Displacement On Half Precision Platforms.

If the problem still persists, and you are using mesh and/or splines inputs, then it is likely due to mesh aliasing. A solution is blurring the LOD targets which can be enabled at Water Renderer ‣ Simulations ‣ Water Level ‣ Blur.

For splines specifically, increasing the mesh density by increasing Subdivisions may also be required. This can be done for the Water Level Input only by overriding the settings.

Tip

These artifacts can be hidden well enough with waves and/or normal maps which can save some performance.