Skip to content

raisin::WaterBody ​

struct · #include <rayrai/Water.hpp>

A body of water drawn by RayraiWindow::setWaterBody().

Light in the water is absorbed and scattered (coefficients per metre, linear RGB): the floor fades with exp(-(absorption + scattering) * path) and the water takes the color of the light it scatters toward the camera. Clear sea water absorbs red within a few metres, which makes it blue; more scattering makes it brighter and milkier. The surface reflects the sky and the objects on screen with Fresnel's law for indexOfRefraction and refracts the scene below it.

RayraiWindow::setWaterBody() rejects invalid values with std::invalid_argument (ranges noted per field). Water is drawn by color renders only: depth, segmentation and LiDAR sensors do not see it, and it does not cast shadows or affect the physics.

Public attributes ​

shape ​

cpp
WaterBodyShape shape

Ocean or rectangle.

center ​

cpp
glm::dvec3 center

World position of the water body frame. z is the mean surface height. For a rectangle, x and y are its center; for an ocean they only anchor the wave phases.

halfExtents ​

cpp
glm::vec2 halfExtents

Rectangle half sizes along its local X and Y, metres, (0, 1e5].

depth ​

cpp
float depth

Rectangle: depth of the water below its mean level, metres, (0, 1e4]. The camera is under water only between this bottom and the surface. An ocean has no bottom.

yawRadians ​

cpp
float yawRadians

Rotation of the body frame about +Z; wave directions are in this frame.

edgeFadeDistance ​

cpp
float edgeFadeDistance

Rectangle: waves fade out over this distance inside its edges, metres (>= 0).

waves ​

cpp
std::vector<GerstnerWave> waves

At most kMaxWaterWaves waves; empty gives a still surface.

absorption ​

cpp
glm::vec3 absorption

Absorption coefficient, 1/m (>= 0).

scattering ​

cpp
glm::vec3 scattering

Scattering coefficient, 1/m (>= 0).

scatteringAnisotropy ​

cpp
float scatteringAnisotropy

Henyey-Greenstein g of the scattering, [-0.9, 0.9]; > 0 scatters forward.

indexOfRefraction ​

cpp
float indexOfRefraction

Refractive index, [1, 2].

roughness ​

cpp
float roughness

Surface roughness, [0.01, 1]; waves too fine for the pixel add to it.

rippleStrength ​

cpp
float rippleStrength

Strength of the small ripple normals, [0, 4]; 0 turns them off.

rippleScale ​

cpp
float rippleScale

Size of the ripple pattern, metres, [0.05, 100].

rippleDirection ​

cpp
glm::vec2 rippleDirection

Main ripple travel direction in the body frame (normalized; must not be zero).

foamColor ​

cpp
glm::vec3 foamColor

Foam albedo, linear RGB, [0, 1].

shorelineFoamDepth ​

cpp
float shorelineFoamDepth

Foam where the water is shallower than this, metres (>= 0); 0 turns it off.

crestFoamStrength ​

cpp
float crestFoamStrength

Foam on compressed crests, [0, 1].

crestFoamThreshold ​

cpp
float crestFoamThreshold

Crest foam starts where the horizontal area of the surface is compressed below this fraction of its rest area, [0, 1]; 1 puts foam on every crest, 0 only on folded ones.

causticStrength ​

cpp
float causticStrength

Fraction of the sunlight on the floor below the surface that the waves gather into caustics, [0, 1]; 0 turns them off.

causticScale ​

cpp
float causticScale

Size of the caustic pattern, metres, [0.05, 100].

shorelineFadeDepth ​

cpp
float shorelineFadeDepth

Reflections fade in over this water depth so the shoreline has no hard edge, metres, [0, 10].

flow ​

cpp
WaterFlow flow

Shallow-water simulation of a rectangle; off by default.

RaiSim — physics for robotics and AI.