This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Water Body

Water body enables physical simulation of liquids of different density and viscous behavior. It also models the appropriate buoyant force on submerged objects and wave dynamics as two-way interaction is calculated. Water simulation is visually pleasant and fast enough, so it can be used within a game environment; however, if the mesh is big and dense, it can become quite costly.

Water body can be assigned to the following types of objects:

Notice
In case of an arbitrary mesh, water will not have appropriate shading, but all physical properties will still be present.

See also#

Mesh Requirements#

A mesh, to which a Water body is assigned, should meet the requirements given here. Mesh requirements are the same for both Dynamic Mesh and Water Mesh objects.

Grid Simulation Model#

The Water body is modeled as a two-dimensional grid with point particles positioned in the vertices of the mesh. The particle movement is restricted to two directions: it can be lifted upwards or dragged downwards. In the case of changing its position, the particle acquires a velocity that affects the neighboring particles and thus describes the grid of Water body at each physics time step. Thus, the waves are generated when physical bodies get in contact with water or a particle is directly assigned new velocity.

Water grid changes during physics simulation

Liquidity#

Liquidity defines the viscosity of water (or any other liquid): it determines how readily it splashes and affects wave formation. It multiplies the speed with which water particles pass velocity vectors to the neighboring ones.

  • The higher the value, the more viscous the water is and the smaller are the waves risen by the objects (e.g. syrup).
  • Low values provide higher surface waves (e.g. tap water).

    Notice
    Be careful not to set too high or too low values, because that may lead to unstable simulation and blowing up of the water. To regain stability, try to tweak Interaction.

Density#

Density of water determines the buoyancy of objects according to Archimedes' principle. Based on the volume of the submerged part of the shape and its mass, buoyancy force is applied to its center of mass and pushes the object upwards, whereto the mean normal of the grid covered by submerged shape points.

  • By the minimum value of 0, the objects will not float in the water, but rather fall through it without any resistance.
  • Higher values increase the buoyant force. If set too high, the immersed objects start to be pushed out in the air.

Physical Behavior of Objects in Water#

Two-way dynamic interaction provides both physically and visually convincing simulation of the waves from the physical bodies as they disturb the fluid. Imagine a moving boat that forms a wake wave behind it, or a character creating ripples while moving in the water (see the picture above).

Interaction with Objects#

A physical object submerged into the water (or any other liquid) has its own velocity vector. On the other hand, all the water particles that are covered by this physical body or surround it, have their own integrated velocity vector, which approximates the state of water. The Interaction value is a coefficient that determines how much the object's velocity influences the velocities of water particles and thus generate waves.

  • By the minimum value of 0, an object produces no disturbances on the water surface.
  • Higher values make the disturbances of water surface more intense and the waves from moving objects become higher.

    Notice
    Too high values may blow the water up, as the law of conservation of energy does not constrain the system! Try decreasing damping values to regain stability.

Linear Damping and Angular Damping#

Objects getting into the water are expected to slow down, as resistance of the water is higher than the drag in the air. Damping values work the other way around compared to the Interaction coefficient:

Linear Damping defines how much linear velocity of the submerged object is decreased over time when influenced by velocities of surrounding water particles. And similarly, Angular Damping defines the gradual decrease in the object's rotation. Both linear and angular damping forces are accumulated before being applied.

  • By the minimum value of 0, objects movement is not hindered by the water. As a result, there are no waves in the water.
  • Higher values make the damping of linear or angular velocities more intense, and objects slow down faster as they get into the water. The waves from the objects in this case become more pronounced, as the energy of the system increases.

    Notice
    The water may blow up in case the values are be very high. Try decreasing the Interaction value to regain stability.

Emission of Particles#

It is possible to create an additional visual effect of small droplets, splashes or bubbles on the water when objects fall into it. To enable this effect perform the following steps:

  1. Create a Particle system effect by clicking Create -> Effect -> Particle system in the main menu of UnigineEditor.
  2. Go to the Parameters window.
  3. In the Dynamic section, choose the Spark Emitter to spawn particles by selecting Emitter -> Spark.
  4. Make Particle system a child of the Water Mesh object.

Particles will be generated only when the object first contacts the water surface, while already submerged bodies will float without generating them.

Effect of water splashes

Water Boundaries#

The following parameters relating to water boundaries make it possible to create different types of basins in the game environment. These parameters provide flexibility in setting up physical behavior of water for big natural lakes and small pools.

Depth#

Depth determines the size of waves: high waves are formed in deep waters (e.g. a sea), while only a slight ripple is generated in shallow waters (e.g. a pool):

  • With the minimum value of 0, the objects raise no waves in the water.
  • Higher values result in higher waves generated by moving objects.

Intersection with the Ground#

Intersection of water with the underlying terrain can be necessary, for example, to estimate the actual depth of the water basin. To enable ground intersection perform the following steps:

  1. Make Water Mesh or Dynamic Mesh object a child node of the Terrain or Static Mesh
  2. Check the Intersection box in the Parameters window -> Physics tab -> Body section.

Intersection is implemented in the following way: the rays are traced downwards from the water mesh surface, as far as the Depth distance. If a ray intersects the parent node, the obtained depth is used in calculations; otherwise the preset depth value is used.

Intersection is also traced upward to check if the water is under terrain and there is no need to render it.

Absorption#

Absorption is an option that creates either an effect of a limited basin or, on the contrary, of an open water surface that does not have marked boundaries.

  • If Absorption is enabled, the waves are dispersed along the mesh perimeter. In this case the water level at mesh edges will gradually fall down to zero level.
  • If disabled, the backwash from the wall is simulated: the wave when reaching the brink of the water is reflected and returns in the reversed direction.

Water body absorption: enabled(left) and disabled(right)

Optimizing Simulation#

Updating each frame a huge number of objects located far away from the camera that are hardly distinguishable or observed as a mass is a waste of resources.

To improve performance and avoid the excessive load, water simulation can be updated with a reduced framerate. When the Water body is out of the area specified by the Update Distance Limit parameter, physical calculations are not performed, though objects preserve their buoyancy.

The set of frame rates given below enables you to specify how often the water simulation should be updated when the object is visible, when only its shadow is visible, or when it is not visible at all.

Parameters -> Physics tab -> Periodic Update section
FPS When Object Is Rendered To Viewport Update rate value for the case when the object is rendered to viewport.
FPS When Only Object Shadows Are Rendered Update rate value when the object itself is outside the viewing frustum, and only its shadow is rendered to viewport.
FPS When Object Is Not Rendered At All Update rate value when both the object and its shadow are not rendered to the viewport.
Update Distance Limit Distance from the camera up to which the object should be updated.
Notice
These values are not fixed and can be adjusted by the Engine at any time to ensure best performance.

This feature is enabled with default settings ensuring optimum performance and can be adjusted per-object in the UnigineEditor or via API at run time.

Warning
Be aware that using reduced update frame rate for an object should be carefully considered in your application's logic, as it may lead to various issues with rendering Skinned Mesh and Dynamic Mesh (flickering due to misalignment of objects inside the Water body).

Assigning a Water Body#

To assign a Water body to an object via UnigineEditor perform the following steps:

  1. Open the World Hierarchy window.
  2. Select a Water Mesh or a Dynamic Mesh object to assign the Water body to.

    Notice
    Make sure that the object's mesh meets requirements!
  3. Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> Water.

    Adding a body

  4. Set the body name and change other parameters, if necessary.
Last update: 2023-06-23
Build: ()