public sealed class WaterSurfacePassDraws one zone's water: the selected patches, the far skirt, and the two planes § D8 reads.
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 MaxPatchesThe most patches a zone may select before the rest are dropped.
public const int MaxWavesHow many waves the buffer is sized for.
public static DepthStencilState DepthStateReverse-Z, tested and not written. See the class remarks.
public static RasterizerState RasterBack faces culled, which is what the patch's winding is generated for.
public int IndexCountHow many indices one patch is drawn from.
public int NearPatchesHow many patches the last Upload selected inside the window.
public int FarPatchesAnd how many the far skirt contributed.
public int DroppedPatchesHow many patches the last selection had to drop, over MaxPatches.
public int DrawsHow many draws the last Record made. Zero, one or two.
public ReadOnlySpan<TerrainLodNode> SelectedThe patches the last Upload chose — the skirt's first, then the window's.
Methods (4)
public WaterSurfacePass(IGraphicsDevice device, (WaterMeshShaders Near, WaterMeshShaders Far) shaders, ReadOnlySpan<PixelFormat> formats, PixelFormat depthFormat, int gridQuads = 32)Builds the pass.
public void Upload(WaterSurfaceMesh mesh, in WaterMeshView view, ReadOnlySpan<GerstnerWave> sea, TextureViewHandle info, SamplerHandle sampler, in WaterMeshSettings settings)Selects this frame's patches and stages everything the draw reads.
public void Record(ICommandList commands)Draws what the last Upload staged.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (5)
- WaterDebugDrawVixen.Rendering.Water
- WaterMeshRendererVixen.Rendering.Water
- WaterSurfacePassTestsVixen.Rendering.Water.Tests
- WaterZoneDrawVixen.Rendering.Water
- ZoneVixen.Rendering.Water