Map 3D: the game's water (wind waves, Fresnel, glint, body colour) #298

Manually merged
github merged 29 commits from gh-pr/298/head into gh-pr/298/base 2026-11-26 20:25:30 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 18:21 UTC · original
holdmysocks:six-map3d-water → master · +237 −7 · 5 files · 29 commits · merged 2026-11-25 19:28 UTC

Follows #286 (sky and light) and #287 (shadows), both merged. This PR adds the water. SIX-211.

What it does

The map's sea and the game's water meshes are now shaded from the timecycle's water_* values, instead of a flat blue.

  • Waves. The peak wavelength comes from water_ocean_beaufort_scale and water_ocean_fetch:
    • Beaufort wind speed is 0.836 B^1.5 m/s.
    • The peak frequency is the fetch-limited JONSWAP one, but no lower than a fully developed sea's.
    • The slope variance is the Cox-Munk clean-surface fit.
    • Ten directional waves are summed for the normal, moving at deep-water speed (× water_ripple_speed_scale). Waves shorter than a few pixels fade into roughness, so the far sea doesn't alias.
  • Light.
    • Reflection: Fresnel (n = 1.33, plus water_fresnel_rescale*) mirrors the sky.
    • Glint: GGX for the sun or moon, through the cascaded shadows, with water_direct_light_roughness_mod added to the roughness.
    • Body colour: a third of the single-scattering albedo from water_clip_scattering_* / water_clip_extinction_* (with their scales), tinted by water_clip_fog_color_tint_* × water_clip_fog_brightness.
  • Where water is. The map tiles paint water (and cells with no data, some of them land) in one colour. That paint is shaded as water on the terrain's sea cells: no height, or deeper than 4.5 m below sea level. It blends over one cell at the shore. On higher cells the same paint stays ground (wet sand, beaches). A water plane under every land cell carries the sea to the horizon. This replaces the stair-step blocks.
  • Terrain shadows. The terrain is drawn 1.5 m under its real height, below the placed ground meshes. Its shadow is now looked up at its real height, so the meshes just under it don't blotch it at a low sun.
  • Filtering. Waves fade by the pixel's footprint on the surface (screen derivatives), so grazing views don't alias. The glint keeps a least roughness, so single-pixel sparkles stay out.

Own choices (not decoded)

  • The scale from the water units to coefficients per metre (0.03).
  • The wind direction.
  • The sea depth threshold (4.5 m): the beaches and dunes reach down to about 4 m.
  • That 60 % of the slope variance is drawn as waves.

Not yet

  • Shallow water over the seabed (the water height map from #254).
  • Foam and shore waves.
  • Refraction and underwater fog. The timecycle phase is passed through but not used.
  • Small lagoons inland of the beach show their 8 m cells as stair-step edges.
  • Inland cells with no data are shaded as water.

Checked

  • cargo check -p sixng-gui --tests gives no warnings.
  • naga validates both modules.
  • New tests: sea_waves_grow_with_wind, and the scene layout test for the larger uniform.
  • On an RTX 3090 (Vulkan), release build, with all game files: cargo test -p sixng-gui atmo:: shadow:: gives 7 passed, with no panics and no wgpu validation errors.
  • Open sea from 500 m and 3000 m: a deep-water gradient with no stair steps, and a golden sunset glint at 19.6 h.
  • Beach at 30 m, 13 h and 18.5 h: dry sand with no false pools. At a low sun the sand is clean and matches --no-shadows apart from real shadows. Pole, building and tree shadows still fall on the terrain.
  • No wave moiré or glint checker in near or grazing views.
  • Frame time: 26-47 ms at the test poses (16-50 fps with 600-2900 models loaded). Render CPU 4.9-6.1 ms at the beach, 24-27 ms in the city with shadows.
**@⁠holdmysocks** on GitHub · 2026-11-25 18:21 UTC · [original](https://github.com/holdmysocks/SixNG/pull/298) `holdmysocks:six-map3d-water` → `master` · +237 −7 · 5 files · 29 commits · merged 2026-11-25 19:28 UTC Follows #286 (sky and light) and #287 (shadows), both merged. This PR adds the water. SIX-211. ## What it does The map's sea and the game's water meshes are now shaded from the timecycle's `water_*` values, instead of a flat blue. - **Waves.** The peak wavelength comes from `water_ocean_beaufort_scale` and `water_ocean_fetch`: - Beaufort wind speed is `0.836 B^1.5` m/s. - The peak frequency is the fetch-limited JONSWAP one, but no lower than a fully developed sea's. - The slope variance is the Cox-Munk clean-surface fit. - Ten directional waves are summed for the normal, moving at deep-water speed (× `water_ripple_speed_scale`). Waves shorter than a few pixels fade into roughness, so the far sea doesn't alias. - **Light.** - Reflection: Fresnel (n = 1.33, plus `water_fresnel_rescale*`) mirrors the sky. - Glint: GGX for the sun or moon, through the cascaded shadows, with `water_direct_light_roughness_mod` added to the roughness. - Body colour: a third of the single-scattering albedo from `water_clip_scattering_*` / `water_clip_extinction_*` (with their scales), tinted by `water_clip_fog_color_tint_*` × `water_clip_fog_brightness`. - **Where water is.** The map tiles paint water (and cells with no data, some of them land) in one colour. That paint is shaded as water on the terrain's sea cells: no height, or deeper than 4.5 m below sea level. It blends over one cell at the shore. On higher cells the same paint stays ground (wet sand, beaches). A water plane under every land cell carries the sea to the horizon. This replaces the stair-step blocks. - **Terrain shadows.** The terrain is drawn 1.5 m under its real height, below the placed ground meshes. Its shadow is now looked up at its real height, so the meshes just under it don't blotch it at a low sun. - **Filtering.** Waves fade by the pixel's footprint on the surface (screen derivatives), so grazing views don't alias. The glint keeps a least roughness, so single-pixel sparkles stay out. ## Own choices (not decoded) - The scale from the water units to coefficients per metre (0.03). - The wind direction. - The sea depth threshold (4.5 m): the beaches and dunes reach down to about 4 m. - That 60 % of the slope variance is drawn as waves. ## Not yet - Shallow water over the seabed (the water height map from #254). - Foam and shore waves. - Refraction and underwater fog. The timecycle phase is passed through but not used. - Small lagoons inland of the beach show their 8 m cells as stair-step edges. - Inland cells with no data are shaded as water. ## Checked - `cargo check -p sixng-gui --tests` gives no warnings. - naga validates both modules. - New tests: `sea_waves_grow_with_wind`, and the scene layout test for the larger uniform. - On an RTX 3090 (Vulkan), release build, with all game files: `cargo test -p sixng-gui atmo:: shadow::` gives 7 passed, with no panics and no wgpu validation errors. - Open sea from 500 m and 3000 m: a deep-water gradient with no stair steps, and a golden sunset glint at 19.6 h. - Beach at 30 m, 13 h and 18.5 h: dry sand with no false pools. At a low sun the sand is clean and matches `--no-shadows` apart from real shadows. Pole, building and tree shadows still fall on the terrain. - No wave moiré or glint checker in near or grazing views. - Frame time: 26-47 ms at the test poses (16-50 fps with 600-2900 models loaded). Render CPU 4.9-6.1 ms at the beach, 24-27 ms in the city with shadows.
sixng-core daylight: resolves the 12 weather types (weather type -> base
cycle GLOBAL region + modifier stack with submodifiers), interpolates the
13 time samples with their easing, and derives sun/moon direction, colour
and strength, ambient tint and strength and exposure. sixng daylight
prints them. The model view's Light section gets a weather list; viewer
default keeps the old light set-up.
Sunrise ~06:10 and sunset ~19:50 match where the cycle's directional
colours change from moonlight to sunlight; the sky stays lit down to -10
degrees.
HDR frame for the 3D map: the timecycle's atmosphere (sky_new_*) rendered
with transmittance, multiple-scattering, sky-view and aerial-perspective
tables; sun, moon, stars and air glow; surfaces lit by the sun's
illuminance through the air and the sky's ambient cube; the two height
fog layers; an exposure meter with the timecycle's percentiles, key value
and adaptation; bloom, contrast, saturation and a filmic curve. Weather
picker and --weather for Map 3D. The model viewer keeps its own light.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:25:29 +00:00
github manually merged commit 28fb68b489 into gh-pr/298/base 2026-11-26 20:25:30 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.