public sealed class WaterSurfaceMeshWhich patches of water a view draws, and where each of their vertices lands.
Remarks
The terrain's quadtree with a different height source ([35 § D4](../../docs/plan/35-water.md#d4-the-surface-is-the-terrains-quadtree-with-a-different-height-source)). PatchSelector selects the nodes, morphs them and guarantees no cracks; every word of the terrain's CDLOD argument is true of water, and the only difference is what the vertex stage samples for height — a heightmap mip chain there, the info field plus the wave sum here. Unreal has two quadtrees, two morph implementations and two sets of debug commands; this is the other answer.
The finest node's vertex spacing is the info field's texel spacing, by construction. The root spans the window's Resolution − 1 quads rounded up to whole patches, so a 512 m window at 257 texels gives 256 quads at two metres — one vertex per texel at level zero. Any other choice makes the surface either carry detail the field cannot supply or throw away detail it can.
⚠ The node's error metric includes the sea state's maximum amplitude, not just the height range. § D4 asks for "density where the waves are, not where the ground is", and the bound is the harder half of it: a node bounded by its rest height is a node culled away while a crest is still in front of the camera, and the symptom is a strip of missing sea that appears only in a swell.
Fields and properties (8)
public WaterFieldDescription WindowThe window the mesh covers. Its origin follows the field's.
public int GridQuadsHow many quads the shared grid patch spans.
public float MetresPerQuadHow many metres one quad of the finest level covers.
public PatchSelector SelectorThe descent, shared with the terrain.
public TerrainLodRanges RangesWhere each level takes over.
public float MaximumAmplitudeThe tallest the sea state can be above its rest height, in metres.
public float FarDistanceHow far past the window the far mesh reaches, in metres.
public float EdgeFadeHow wide the band is over which the waves fade out at the window's edge, in metres.
Methods (7)
public WaterSurfaceMesh(in WaterFieldDescription window, TerrainLodRanges ranges, int gridQuads = 32)Builds a mesh over a window's shape.
public void Update(WaterFieldPyramid reduced, float maximumAmplitude)Points the mesh at a field, and tells it how tall the sea is.
public int Select(Vector3 viewPosition, in BoundingFrustum frustum, ICollection<TerrainLodNode> nodes)Chooses the patches inside the window a view draws.
public int SelectFar(in BoundingFrustum frustum, float restHeight, ICollection<TerrainLodNode> nodes)Chooses the skirt patches beyond the window — the far mesh.
public Vector2 GroundOf(in TerrainLodNode node, int gridX, int gridZ)Where one vertex of a patch lands on the ground plane, after morphing.
public float EdgeDamping(Vector2 position)How much of the sea state survives at a place, before the depth attenuation.
public (Vector3 Position, Vector3 Normal) PositionOf(in TerrainLodNode node, int gridX, int gridZ, in WaterEvaluator evaluator, float waterTime)Where one vertex of a patch lands in the world, waves included.
Used by (8)
- WaterDebugDrawVixen.Rendering.Water
- WaterDebugDrawTestsVixen.Rendering.Water.Tests
- WaterMeshRendererVixen.Rendering.Water
- WaterSurfaceMeshTestsVixen.Water.Tests
- WaterSurfacePassVixen.Rendering.Water
- WaterSurfacePassTestsVixen.Rendering.Water.Tests
- WaterZoneDrawVixen.Rendering.Water
- ZoneVixen.Rendering.Water