Vixen
c7401864
csharp
public sealed class WaterField

Every body in a region, resolved once into a field over the ground plane.

Read the guide page for this →

Remarks

The interchange ([§ D3](../../docs/plan/35-water.md#d3-the-water-info-texture-is-the-interchange-and-it-is-a-zone-render)). Every consumer wants a field over the ground plane rather than a set of bodies: the material wants depth for its colour and its shoreline, the vertex stage wants attenuation, the foam wants the gradient, the ripple simulation wants a boundary, and none of them wants to iterate bodies per pixel.

Bodies are rasterised in priority order, which is what resolves a river mouth. Two flow models meet exactly once — where a river runs into a lake — and resolving it here, once, is what lets a tile of the surface carry one material instead of a blend that has to know which two bodies it is between.

This is the CPU form. W3 renders the same four channels top-down into a texture; what makes the two agree is that both are this arithmetic. The fifth channel here — coverage — is what the mesh's descent predicate tests, and how it is packed on the device is W3's to decide.

Fields and properties (2)

  • public WaterFieldDescription Description

    The window it covers and the rate it covers it at.

  • public int CoveredTexels

    How many texels any body claimed, after the last rasterisation.

Methods (6)

  • public WaterField(in WaterFieldDescription description)

    Creates an empty field of a shape.

  • public void Move(in WaterFieldDescription description)

    Moves the window without reallocating, and forgets what was in it.

  • public void Clear()

    Forgets everything the field holds.

  • public void Rasterize(IReadOnlyList<WaterBody> bodies, IWaterGround beneath)

    Rasterises every body and the ground beneath them.

  • public WaterFieldSample Sample(Vector2 position)

    What the field says about a place, interpolated between its texels.

  • public WaterFieldSample At(int x, int z)

    What the field holds at one texel, unfiltered.

Used by (16)

  • BuoyancyTestsVixen.Water.Tests
  • IWaterFieldSourceVixen.Water
  • LakeVixen.Water.Physics.Tests
  • WaterDebugDrawVixen.Rendering.Water
  • WaterEvaluatorVixen.Water
  • WaterEvaluatorTestsVixen.Water.Tests
  • WaterFieldPyramidVixen.Water
  • WaterFieldTestsVixen.Water.Tests
  • WaterInfoTextureVixen.Rendering.Water
  • WaterQueryVixen.Water
  • WaterSurfaceMeshVixen.Water
  • WaterSurfaceMeshTestsVixen.Water.Tests
  • WaterZoneStateVixen.Water
  • WaterZoneSystemTestsVixen.Rendering.Water.Tests
  • WaterZoneTestsVixen.Water.Tests
  • WaterPresenterVixen.Editor.App