Skip to content

[Lighting Overhaul][Phase 3] Unify terrain lighting, atmosphere, and output #901

Description

@MichaelFisher1997

Parent

Part of #898.

Depends on

#900, #899, and #903.

Goal

Replace simple/legacy/partial-PBR branching with one atmosphere-driven, scene-linear PBR-lite model matching the selected cinematic saturated art direction.

Scope

  • Remove the hard-coded simple_lighting_mode override.
  • Collapse terrain simple, legacy, and partial-PBR branches into one shared lighting equation.
  • Use Lambert diffuse plus restrained dielectric GGX specular; metalness remains zero unless explicitly authored.
  • Compose directional sun/moon, hemispherical sky irradiance, subtle neutral ground bounce, propagated skylight, and colored RGB block light.
  • Apply mesh AO and SSAO only to indirect diffuse, not direct sun or specular.
  • Add a controlled readable-dark indirect floor without converting low-light albedo to gray-blue.
  • Correct camera-relative view vectors and TBN handedness.
  • Produce sun radiance, sky/ground irradiance, fog/scattering colors, and exposure from one atmosphere state.
  • Keep terrain, sky, fog, water inputs, and future volumetrics on the same atmosphere contract.
  • Keep albedo sampling in sRGB hardware decode and all lighting/composition in linear HDR.
  • Use one AgX-style tone map and exactly one display encoding step.
  • Move cinematic saturation/contrast into an authored LUT; remove mandatory applyLushGrade stacking and hard-coded cyan cave/sky terms.
  • Retune presets so they share the same visual model and differ only in feature quality/cost.

Acceptance criteria

  • HIGH/ULTRA settings are no longer silently overridden by simple lighting.
  • Caves are dark but readable and preserve material chroma.
  • Day, sunset, night, and emissive lighting remain coherent without a global cyan cast.
  • Direct, indirect, AO, shadow, and block-light debug channels sum to the final result predictably.
  • Absolute world position does not alter Fresnel/specular response.
  • Windowed and headless output remain color-equivalent.
  • All presets retain the same lighting semantics.

Verification

nix develop --command zig build test
nix develop --command zig build -Dskip-present
nix develop --command zig build run -Dskip-present -Dauto-world=normal -Dscreenshot-path=screenshots/lighting-phase3-world.png -Dscreenshot-frame=180 -Dscreenshot-delay-seconds=3
nix develop --command zig build benchmark -Doptimize=ReleaseFast -Dbenchmark-preset=high -Dbenchmark-duration=60 -Dbenchmark-output=lighting-phase3-high.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions