Skip to content

Water: shore distance field, shoreline strip and foam, GotA water panel - #101

Open
RowDaBoat wants to merge 1 commit into
mainfrom
water-shore-field
Open

RowDaBoat wants to merge 1 commit into
mainfrom
water-shore-field

Conversation

@RowDaBoat

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #98. Reworks how polyworld/waters finds shorelines, and tunes Gods of the Arena's lakes.

  • Shore distance field (waters.nim): the per-pixel screen-space shore march is replaced by a distance field baked once per water layer from the terrain. The bake samples the visible ground (solid layers plus ground relief) at 4 samples per world unit over the water and an 8-unit margin; ground above the water's surface is land. An exact Euclidean distance transform (Felzenszwalb–Huttenlocher, columns then rows) stores each sample's distance to the nearest land in a filtered R16F texture. The water reads it once per pixel, so the shoreline is smooth, follows the visible bank, and no longer changes with the camera or rings units standing in the water. Fields are built lazily by drawWaterBody; buildShoreFields() rebuilds them after terrain edits. shoreHeight is removed.
  • Shoreline strip and foam: the shoreline is a flat strip foamDistance wide with a soft outer edge. foamNoise (0–1) breaks it into foam: tileable noise flow-mapped toward the shore along the field's gradient (the exact direction to the nearest shore), with foamScale and foamSpeed. The shore fade still blends water and strip into the bank.
  • Gods of the Arena:
    • Lakes use a tuned GotaLakeWater preset (deep turquoise (0, 0.52, 0.77), colour strength 0.54, foam scale 1.22 and speed 0.1, fade 0.96 / curve 1.97).
    • The lake list now takes its parameters from lakeWater each frame, so they can change at runtime.
    • -d:waterPanel adds a developer window (F4) with every water parameter, plus colour pickers (saturation/value square, hue bar, swatch and RGB sliders) for the water and shoreline colours. It isn't compiled into normal or web builds.

Merged onto the renderer-performance rework (captureScene, beginReflection and drawWaterBody called inline by GotA).

Testing

  • tests/all.nim: CI tests passed
  • Native builds: GotA (default, -d:waterPanel, -d:headless), Light vs Dark, Call to Adventure
  • GotA web viewer built and played in headless Chrome (SwiftShader WebGL2): no shader, WebGL or runtime errors
  • GotA native screenshots: smooth shoreline strip and foam along the lake banks; no rings around units in the water; water colour measured against the target

🤖 Generated with Claude Code

…-space shore march

feat: flat shoreline strip with optional flow-mapped foam noise
feat: Gods of the Arena water panel with every water parameter and colour pickers, behind -d:waterPanel
change: Gods of the Arena lakes tuned to a deep turquoise
change: GotA lake parameters can change at runtime

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant