Skip to content

[Lighting Overhaul][Phase 1] Rewrite world-level voxel lighting and relight migration #899

Description

@MichaelFisher1997

Parent

Part of #898.

Depends on

#900.

Goal

Replace duplicated chunk-local lighting with one authoritative world-level system whose output is cross-chunk, deterministic, mutation-safe, and compatible with existing worlds.

Scope

  • Introduce a WorldLightingEngine used by generation, loading, and runtime mutations.
  • Centralize block opacity, light transmission/attenuation, and RGB emission rules.
  • Seed direct skylight columns and RGB emitters, then propagate in all six directions across loaded chunk boundaries.
  • Add proper addition/removal queues that follow the full light influence rather than a one-chunk edit box.
  • Reconcile light frontiers when a chunk loads, generates, or gains a neighbor; results must not depend on load order.
  • Use one water/translucent attenuation rule for generation and runtime updates.
  • Remove entrance_bounce and entrance_dir; ordinary propagated skylight becomes the source of cave-entrance illumination.
  • Add chunk content/light revisions or immutable meshing snapshots. Publish a worker mesh only when its captured revision still matches.
  • Add a lighting algorithm version to world metadata. Existing worlds keep blocks but ignore stale derived light and relight asynchronously on load.
  • Keep chunks non-renderable until the required local light frontier is stable; avoid a one-frame black or fullbright flash.
  • Keep GPU meshing disabled until it can consume the same light data and vertex contract.

Acceptance criteria

  • Skylight and RGB emitters propagate seamlessly across chunk boundaries.
  • Placing/removing opaque and emissive blocks updates every affected loaded chunk.
  • Results are identical for different chunk generation/load orders.
  • Water/translucent attenuation is identical before and after runtime relighting.
  • Existing version-two worlds load and relight without block or biome loss.
  • No stale mesh can overwrite a newer block/light revision.
  • Cave entrance, sealed cave, torch, and cross-chunk corridor tests pass.
  • Entrance-light storage and vertex attributes are removed after migration.

Required tests

  • Cross-chunk skylight in all four horizontal directions and corners.
  • Cross-chunk RGB addition and removal from local coordinates 0 through 15.
  • Upward/downward propagation and enclosed-cave behavior.
  • Load-order permutation tests.
  • Relight-on-load migration fixture.
  • Mutation-versus-meshing revision rejection.

Verification

nix develop --command zig fmt modules/world-core/src modules/world-runtime/src modules/world-meshing/src modules/world-persistence/src modules/worldgen-common/src
nix develop --command zig build test
nix develop --command zig build -Dskip-present
nix develop --command zig build run -Dskip-present -Dauto-world=normal -Dstartup-diagnostic-seconds=5

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