underwater.module
This package holds more than this page lists. See all of its files in its world.
README.md
underwater
The view from inside every Tidewater water. Kinds call
Underwater.register(physicsName, { fogColor, absorption?, density?, causticStrength?, causticScale?, causticFalloff?, shafts?, materials? }) with the name they gave
Physics.defineWater, and Underwater.unregister(physicsName) on destroy.
Each frame (driven by the underwater render feature, with a task loop fallback)
it reads Physics.water at the camera; while the camera is below (or within the
waterline band of) a body, it enables the underwaterPost post effect fed from
that body's profile and the scene's sun (fog, caustics, light shafts, wobble,
waterline split), and sets underwater_mode = 1 on the body's listed surface
materials. Underwater.isUnder() answers (under, body); Underwater.setEnabled
turns the whole view off; Underwater.setViewer(cameraId) makes it follow a camera
that is not on screen (a cutscene or capture camera; nil goes back to the active
one). The sun is read from the scene's strongest directional light (direction,
colour, intensity), so a low evening sun gives slanted shafts and faint caustics and
a sun under the horizon gives the moonlit column. The caustics are a drifting
two-layer Voronoi net that brightens its filaments and dims the cells between them;
the surface seen from below is Snell's window (the sky squeezed into a ~97° disc,
the dim water mirrored outside it). A body nobody registered is drawn with a default
lake profile.