Vixen
c7401864
csharp
public sealed class WaterSurfacePass

Draws one zone's water: the selected patches, the far skirt, and the two planes § D8 reads.

Read the guide page for this →

Remarks

[35 § D4](../../docs/plan/35-water.md#d4-the-surface-is-the-terrains-quadtree-with-a-different-height-source). All the water in a zone is one draw call, and the far mesh is a second — the same instanced grid patch, placed by one WaterNodeRecord each, sharing the terrain's index buffer because the lattice is the same lattice.

⚠ Depth is tested and not written, and that is what makes § D8's pass possible at all. The composite unprojects the scene depth to find what is behind the water; a surface that wrote depth would put itself there and the water would be integrated against itself. Testing is still necessary — a lake behind a hill must not draw over it — so the state is reverse-Z Greater with writes off.

⚠ The far mesh is drawn first, and the order is load-bearing. With depth writes off nothing arbitrates between two fragments at one pixel except which came last, and the near mesh is the one with the field under it. Drawing the skirt afterwards would overwrite the window with a flat plane wherever the two overlap at the horizon.

Two pipelines for one shader, because the far mesh is a permutation. § D4's own wording: "drawn with a permutation that skips the wave sum and the flow". It is one shader and one layout, so the second pipeline costs a compile and nothing per frame.

Fields and properties (10)

  • public const int MaxPatches

    The most patches a zone may select before the rest are dropped.

  • public const int MaxWaves

    How many waves the buffer is sized for.

  • public static DepthStencilState DepthState

    Reverse-Z, tested and not written. See the class remarks.

  • public static RasterizerState Raster

    Back faces culled, which is what the patch's winding is generated for.

  • public int IndexCount

    How many indices one patch is drawn from.

  • public int NearPatches

    How many patches the last Upload selected inside the window.

  • public int FarPatches

    And how many the far skirt contributed.

  • public int DroppedPatches

    How many patches the last selection had to drop, over MaxPatches.

  • public int Draws

    How many draws the last Record made. Zero, one or two.

  • public ReadOnlySpan<TerrainLodNode> Selected

    The patches the last Upload chose — the skirt's first, then the window's.

Methods (4)

Used by (5)

  • WaterDebugDrawVixen.Rendering.Water
  • WaterMeshRendererVixen.Rendering.Water
  • WaterSurfacePassTestsVixen.Rendering.Water.Tests
  • WaterZoneDrawVixen.Rendering.Water
  • ZoneVixen.Rendering.Water