Click or drag to resize
DigitalRuneWaterFlow Class
Defines the direction and speed of water flow.
Inheritance Hierarchy
SystemObject
  DigitalRune.GraphicsWaterFlow

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class WaterFlow : IDisposable

The WaterFlow type exposes the following members.

Constructors
  NameDescription
Public methodWaterFlow
Initializes a new instance of the WaterFlow class.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by an instance of the WaterFlow class.
Protected methodDispose(Boolean)
Releases the unmanaged resources used by an instance of the WaterFlow class and optionally releases the managed resources.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyBaseVelocity
Gets or sets the uniform, constant velocity applied to the whole water surface.
Public propertyCycleDuration
Gets or sets the cycle duration in seconds of a normal map layer.
Public propertyFlowMap
Gets or sets the texture which defines the flow direction and speed.
Public propertyFlowMapSpeed
Gets or sets the scale factor for flow-map-based flow.
Public propertyMaxSpeed
Gets or sets the maximal speed limit.
Public propertyMinStrength
Gets or sets the minimum strength of the normal maps.
Public propertyNoiseMapScale
Gets or sets the world space scale of the noise map.
Public propertyNoiseMapStrength
Gets or sets the noise strength.
Public propertySurfaceSlopeSpeed
Gets or sets the scale factor for surface-slope-based flow.
Top
Remarks

This class can be used to make the water of a WaterNode flow in user-defined directions and with user-defined speed.

Defining Flow:
Water flow is defined by three influences:

  • BaseVelocity defines a uniform constant flow which is applied to the whole water surface.
  • Water flow can also be defined by surface slope of the water surface. The slope is defined by the vertex normals of the water Volume. Water is usually running downhill. SurfaceSlopeSpeed defines the speed at which water flows down an inclined water surface.
  • A FlowMap texture can be used to define a detailed, complex flow pattern. FlowMapSpeed scales the speed defined by the flow map.

Speed and Normal Strength Limits:
Flow speed from all three influences (base velocity, surface slope and flow map) is summed up and clamped to MaxSpeed. The intensity of normal maps should be reduced if the water moves faster. The normal map strength have full strength when the flow speed is zero. The normal map strength is reduced to MinStrength when the flow speed reaches its maximum (MaxSpeed).

Reference frame:
The BaseVelocity is relative to the local space of the WaterNode. The FlowMap is also relative to the WaterNode; it is aligned with the local axes of the node. It fills the local AABB, and the map is always projected top-down.

Rendering Flow:
Water flow is created by scrolling the normal maps of the water into the flow direction. If two points on the water surface have a different flow direction or flow speed, then this creates distortion. To hide the distortions, two layers of normal maps are alternated: One normal map layer fades in, is scrolled and before it gets too distorted it fades out. At the same time a second normal map layer is added but with a half cycle offset. CycleDuration defines the cycle period. The normal map cycling can cause pulsing artifacts. Noise can be used to hide this artifact, by giving each point on the water surface a different cycle offset. NoiseMapScale defines the scale of the applied noise texture in x and z direction. NoiseMapStrength defines how much noise is applied to each pixel (= how much a cycle can be offset). The noise map itself is always generated automatically.

Limitations: Currently, the WaterRenderer does not render WaterFlow when the WaterNode also uses WaterWaves.

See Also