Vixen
c7401864
csharp
public sealed class UnderwaterRenderer

The waterline: what a camera straddling the surface sees, divided by a curve.

Read the guide page for this →

Remarks

[35 § D9](../../docs/plan/35-water.md#d9-underwater-is-a-post-process-volume-and-the-waterline-is-named-as-the-hard-part)'s second half, and the document warns about it twice. "Designing the volume path first and discovering the waterline second is how you get a system where the transition is a hard cut and the fix is architectural." The volume path is UnderwaterShape over doc 32's fold and it grades the whole frame; this is the other feature, which a fold cannot be.

⚠ A fold produces one weight and a waterline is a curve. A camera half in the water needs two treatments in one frame divided by the intersection of the wave surface with the near plane — which is a per-pixel question, and no number the volume system can produce is an answer to it.

⚠ The local surface plane rather than the wave sum, and the approximation is stated. The exact answer needs the info texture and the Gerstner sum bound into a post-process node, which is a second place for § D2's seam test to have to hold. Over the few centimetres a near plane spans, a wave is its own tangent plane to well under a millimetre. What it costs is a crest smaller than the near plane passing the camera, which is spray rather than a waterline.

⚠ The plane comes from the same WaterQuery the volume fold and the buoyancy solver read, at the same water time — § D2 applied to one more consumer. A waterline drawn against the rest height would sit at mean sea level while the drawn surface moved around it, which reads as the camera being wrong rather than the line being wrong.

⚠ The distortion and the caustics are the volume's and not the lens's, which § D9 says outright: they are driven by the submersion depth the fold computes, so a head just under the surface wobbles and one at ten metres does not. A lens property would wobble a cutscene camera flying over the lake.

Fields and properties (34)

  • public required string Output

    The target it writes — the frame's scene colour.

  • public required string Behind

    The copy of the frame so far, which is what it grades.

  • public required string SceneDepth

    The opaque scene's depth, which says how far the fog has to reach.

  • public required string Surface

    The surface plane: device depth in r, coverage in g.

  • public RenderView? View

    The view the camera matrices are derived from, or null to set them by hand.

  • public WaterZoneSystem? Zones

    Where the zones — and therefore the local surface plane — come from.

  • public Matrix4x4 InverseViewProjection

    Clip back to world, when no View supplies it.

  • public Vector3 CameraPosition

    Where the camera is, which the path lengths are measured from.

  • public Vector3 SurfacePoint

    A point on the surface near the camera. Set from Zones when there is one.

  • public Vector3 SurfaceNormal

    The surface's normal there, which is what tilts the waterline with the swell.

  • public float Submersion

    How far below the surface the camera is, in metres. Negative is above.

  • public float WaterlineFeather

    How wide the waterline's fade is, in metres.

  • public Vector3 Scattering

    How much light the medium scatters out of a ray per metre, per channel.

  • public Vector3 Absorption

    How much it absorbs per metre, per channel.

  • public float PhaseG

    Henyey–Greenstein anisotropy, carried so the medium is one description.

  • public Vector3 SkyColour

    What arrives from the whole sky. ⚠ Without it everything below the surface is black.

  • public Vector3 BehindScale

    § D8's scale on what shows through.

  • public bool Distortion

    Whether what is seen is refracted at all.

  • public float DistortionAmount

    How far the refraction wobble displaces what is seen, in UV.

  • public float DistortionScale

    How many wobbles across the screen, and how fast they travel.

  • public float DistortionSpeed

    How fast the wobble travels.

  • public bool Caustics

    Whether the moving caustic bands are added.

  • public float CausticAmount

    How bright they are.

  • public float CausticScale

    How large a caustic cell is.

  • public float CausticSpeed

    How fast the pattern drifts.

  • public float CausticDepth

    How deep the caustics fade out over, in metres.

  • public float WaterTime

    The simulation's water time, in seconds.

  • public EffectPipelineDescriber? Modules

    Where shader modules come from. Set before the first frame that builds.

  • public SamplerCache? Samplers

    Where samplers come from, shared so a frame does not exhaust the device's supply.

  • public DescriptorAllocator? Allocator

    Where the pass's descriptor sets come from.

  • public IGraphicsDevice? Device

    The device its pipelines and its uniform block are created on.

  • public FullScreenRenderer Pass

    The pass this node is, for a host that wants to look at what it did.

  • public int BuildCount

    How many frames have declared the pass.

  • public bool IsSubmerged

    Whether the last build found the camera under water at all.

Methods (3)

  • public UnderwaterRenderer()

    Creates the node.

  • protected override void Build(GraphicsCompositor compositor, CompositorFrame frame)

    Declares this node's render-graph passes.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (3)

  • UnderwaterPassImageTestsVixen.Graphics.Golden.Tests
  • UnderwaterPassTestsVixen.Rendering.Water.Tests
  • WaterRendererFactoryVixen.Rendering.Water