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
WaterBodyShape shapeOcean or rectangle.
center
glm::dvec3 centerWorld 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
glm::vec2 halfExtentsRectangle half sizes along its local X and Y, metres, (0, 1e5].
depth
float depthRectangle: 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
float yawRadiansRotation of the body frame about +Z; wave directions are in this frame.
edgeFadeDistance
float edgeFadeDistanceRectangle: waves fade out over this distance inside its edges, metres (>= 0).
waves
std::vector<GerstnerWave> wavesAt most kMaxWaterWaves waves; empty gives a still surface.
absorption
glm::vec3 absorptionAbsorption coefficient, 1/m (>= 0).
scattering
glm::vec3 scatteringScattering coefficient, 1/m (>= 0).
scatteringAnisotropy
float scatteringAnisotropyHenyey-Greenstein g of the scattering, [-0.9, 0.9]; > 0 scatters forward.
indexOfRefraction
float indexOfRefractionRefractive index, [1, 2].
roughness
float roughnessSurface roughness, [0.01, 1]; waves too fine for the pixel add to it.
rippleStrength
float rippleStrengthStrength of the small ripple normals, [0, 4]; 0 turns them off.
rippleScale
float rippleScaleSize of the ripple pattern, metres, [0.05, 100].
rippleDirection
glm::vec2 rippleDirectionMain ripple travel direction in the body frame (normalized; must not be zero).
foamColor
glm::vec3 foamColorFoam albedo, linear RGB, [0, 1].
shorelineFoamDepth
float shorelineFoamDepthFoam where the water is shallower than this, metres (>= 0); 0 turns it off.
crestFoamStrength
float crestFoamStrengthFoam on compressed crests, [0, 1].
crestFoamThreshold
float crestFoamThresholdCrest 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
float causticStrengthFraction of the sunlight on the floor below the surface that the waves gather into caustics, [0, 1]; 0 turns them off.
causticScale
float causticScaleSize of the caustic pattern, metres, [0.05, 100].
shorelineFadeDepth
float shorelineFadeDepthReflections fade in over this water depth so the shoreline has no hard edge, metres, [0, 10].
flow
WaterFlow flowShallow-water simulation of a rectangle; off by default.