Water System
Glass aquarium walls. Reflective surfaces. Steel reinforcement. The water block is a sculpture.
Architecture
The water system renders as a hybrid two-mesh construction that looks like a single glass block of water:
- Water surface — a flat plane with Babylon.js
WaterMaterial. This gives you real-time reflections, refraction, wave displacement, and Fresnel effects. It's the "lid" on top of the aquarium. - Glass box — a five-face mesh (bottom + four sides, no top) with a
StandardMaterialusing Fresnel parameters. Looking straight through: mostly transparent. Looking at a grazing angle: opaque, blue-tinted, glowing — like thick aquarium glass. - Steel rim — a CSG-constructed hollow square frame that wraps around the water's edge. Dark blue gunmetal finish, sitting at the waterline where the glass meets the surface. It's the "reinforcement pipe" holding the tank together.
All three components are parented to the same transform node and move together when you adjust the water level.
Ocean Water
The ocean is the primary water body. It spans the full terrain size and sits at a user-adjustable height.
| Control | What It Does |
|---|---|
| Enable Ocean | Toggle the entire water system on/off |
| Water Level | Height of the water surface. Raise it to flood valleys, lower it to expose coastlines |
| Thickness | Depth of the glass box below the water surface (defaults to museum block depth) |
Adjust the water level after generating your terrain. The glass box, steel rim, and reflective surface all rebuild automatically to match the new height. No need to regenerate.
Basin Lakes
Basin lakes are auto-detected from terrain drainage. When erosion carves a basin (a closed depression with no outflow), the system fills it with a lake water body. Each lake gets its own glass box and surface mesh sized to fit the basin bounds.
| Control | What It Does |
|---|---|
| Enable Basin Lakes | Toggle basin lake detection |
| Min Basin Size | Minimum basin area (in grid cells) to qualify as a lake |
| Merge Adjacent | Combine nearby basins into larger lakes |
The Glass Material
The aquarium glass effect uses two Fresnel parameters on a standard material:
- Opacity Fresnel — edges (grazing angle) are more opaque; center (straight-through) is more transparent. This creates the thick-glass-edge look.
- Emissive Fresnel — edges glow a subtle blue; center has no glow. This adds the deep-water luminosity you see at the edges of a real aquarium.
Combined with backFaceCulling: false and a base alpha of 0.35, the glass box reads as a solid block of tinted water from any angle.
The Steel Rim
The rim is built using CSG (Constructive Solid Geometry):
- Create an outer box matching the terrain size (plus a small outset so it wraps outside the museum block walls)
- Create an inner box slightly smaller (the wall thickness)
- Subtract inner from outer — the result is a hollow square frame
- Apply a dark blue steel material with high specular
The rim sits with its bottom edge at the water surface and rises above it, like the reinforcement band on an industrial water tank. When you adjust the water level, the rim rebuilds at the new position.