Vixen
c7401864
csharp
public readonly record struct WaterWaveSpectrum

A sea state, as an author edits it.

Read the guide page for this →

Remarks

A spectrum and not a list ([35 § D7](../../docs/plan/35-water.md#d7-waves-are-a-spectrum-summed-as-gerstner-and-the-fft-is-deferred-with-arithmetic)). Wind, a spread, a wavelength range and a seed are the things somebody describing a sea has words for; sixteen amplitudes and phases are not.

⚠ Deterministic from Seed on every host, which is a stated exit criterion rather than a nicety: a client and a server that disagree about the sea disagree about where a boat is. Every draw goes through Hash, which is integer arithmetic and therefore the same everywhere there is a 32-bit word.

Why Gerstner and not an FFT. A sum of sixteen waves is a closed-form function of position and time, so a server can answer "where was the surface six ticks ago" without having simulated the intervening frames — which is what makes a rolled-back buoyancy force answerable at all. An FFT needs a per-frame dispatch chain and a CPU path that either reads back a texture or runs a second transform, and neither can answer that question. When the FFT lands it is a second model behind the same evaluator, and the seam test is what makes adding it safe.

Fields and properties (12)

  • public float WindDirection

    Which way the wind blows, in radians about the vertical axis.

  • public float WindSpeed

    How hard, in metres per second. Drives the amplitude and the wavelength range.

  • public float DirectionalSpread

    How far off the wind a wave may travel, in radians. Zero is a perfectly ordered swell.

  • public float MinimumWavelength

    The shortest wave in the sum, in metres.

  • public float MaximumWavelength

    The longest, in metres.

  • public float WavelengthFalloff

    How amplitude falls off toward the short end, as an exponent on the normalised wavelength.

  • public float AmplitudeScale

    A multiplier on every amplitude the spectrum derives.

  • public float Steepness

    How far the horizontal displacement goes, 0…1.

  • public uint Seed

    Which sea, of all the seas with these numbers.

  • public WaterWaveCount Count

    How many waves it is summed from.

  • public static WaterWaveSpectrum Default

    An open sea in a fresh breeze: sixteen waves, half a metre of swell.

  • public static WaterWaveSpectrum Calm

    A lake: eight short waves, almost no swell, and no wind direction worth having.

Methods (3)

  • public string? Validate()

    Why this spectrum cannot be summed, or if it can.

  • public int Generate(Span<GerstnerWave> into)

    Sums the spectrum into the waves the evaluator reads.

  • public static float MaximumAmplitude(ReadOnlySpan<GerstnerWave> waves)

    The tallest the surface can be above its rest height, in metres.

Used by (37)

  • AssetWaterSourceVixen.Engine.Renderer
  • AssetWaterSourceTestsVixen.Engine.Renderer.Tests
  • IWaterWaveSourceVixen.Rendering.Water
  • LakeVixen.Water.Physics.Tests
  • SeaVixen.Rendering.Water.Tests
  • SwellVixen.Water.Physics.Tests
  • TypeRegistrationVixen.Rendering.Water
  • UnderwaterPassTestsVixen.Rendering.Water.Tests
  • UnderwaterShapeVixen.Rendering.Water
  • UnderwaterShapeTestsVixen.Rendering.Water.Tests
  • Vixen_Rendering_Water_WaterZoneComponentSerializerVixen.Rendering.Water
  • Vixen_Water_WaterWaveSpectrumSerializerVixen.Water
  • Vixen_Water_WaterWavesAssetSerializerVixen.Water
  • WaterDebugDrawTestsVixen.Rendering.Water.Tests
  • WaterEvaluatorTestsVixen.Water.Tests
  • WaterHorizonImageTestsVixen.Graphics.Golden.Tests
  • WaterMeshRendererVixen.Rendering.Water
  • WaterQueryVixen.Water
  • WaterSurfaceMeshTestsVixen.Water.Tests
  • WaterSurfaceSeamDeviceTestsVixen.Graphics.Golden.Tests
  • WaterWaveTestsVixen.Water.Tests
  • WaterWavesAssetVixen.Water
  • WaterZoneComponentVixen.Rendering.Water
  • WaterZoneStateVixen.Water
  • WaterZoneSystemVixen.Rendering.Water
  • WaterZoneSystemTestsVixen.Rendering.Water.Tests
  • WaterZoneTestsVixen.Water.Tests
  • WavesEntryVixen.Engine.Renderer
  • FileWavesVixen.Editor.Assets.Tests
  • IWaterSceneVixen.Editor.SceneView
  • WaterEditTestsVixen.Editor.Water.Tests
  • WaterPresenterVixen.Editor.App
  • WaterSceneSourceVixen.Editor.Water
  • WaterWavesImporterVixen.Editor.Assets
  • WaterWavesImporterTestsVixen.Editor.Assets.Tests
  • WaterZoneSettingsVixen.Editor.Water
  • WaveAdapterVixen.Editor.App