Skip to content

Bake chunk lighting so generated worlds load lit#1055

Merged
louis-e merged 7 commits into
mainfrom
fix/baked-chunk-lighting
May 21, 2026
Merged

Bake chunk lighting so generated worlds load lit#1055
louis-e merged 7 commits into
mainfrom
fix/baked-chunk-lighting

Conversation

@louis-e
Copy link
Copy Markdown
Owner

@louis-e louis-e commented May 21, 2026

Chunks were written as Status=full but without lighting, so off-disk LOD/pre-gen tools (Voxy, Chunky) rendered them dark until visited and relit in-game. Compute SkyLight (vertical cast + flood-fill) and BlockLight (flood-fill from emitters) per section and set isLightOn=1 so the light engine loads them as LIGHT_AND_DATA immediately.

Copilot AI review requested due to automatic review settings May 21, 2026 21:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds baked per-chunk lighting data (SkyLight + BlockLight) to Java Anvil chunks at write time, and marks chunks as pre-lit (isLightOn=1) so generated worlds load with lighting already present (including for off-disk renderers like Voxy/Chunky).

Changes:

  • Compute SkyLight via a vertical cast from the top of the chunk volume followed by a flood-fill.
  • Compute BlockLight via a flood-fill seeded from detected light-emitting blocks in each section palette.
  • Write SkyLight/BlockLight ByteArrays into each section NBT and set root isLightOn to 1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
Comment thread src/world_editor/java.rs Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

⏱️ Benchmark run finished in 0m 56s
🏗️ Generation time: 28s (excl. data fetching)
🧠 Peak memory usage: 932 MB (↗ 3% more)

📈 Compared against baseline: 27s time, 900 MB memory
🧮 Delta: 29s time, 32 MB memory
🔢 Commit: dbfda88

🟢 Generation time is unchanged.
⚠️ This PR increases peak memory.

📅 Last benchmark: 2026-05-21 23:11:22 UTC

You can retrigger the benchmark by commenting retrigger-benchmark.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
@louis-e
Copy link
Copy Markdown
Owner Author

louis-e commented May 21, 2026

retrigger-benchmark

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
louis-e and others added 4 commits May 22, 2026 00:31
Chunks were written as Status=full but without lighting, so off-disk
LOD/pre-gen tools (Voxy, Chunky) rendered them dark until visited and
relit in-game. Compute SkyLight (vertical cast + flood-fill) and
BlockLight (flood-fill from emitters) per section and set isLightOn=1
so the light engine loads them as LIGHT_AND_DATA immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- tinted_glass blocks all light: exclude it from the glass transparency rule
- honour `lit` blockstate for campfire/soul_campfire/redstone_torch emission
- seed the skylight queue during the vertical cast, dropping the second scan

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- restrict skylight flood-fill to the occupied band; bulk-fill open sky
  above the highest opaque block (empty/low chunks become near-free)
- return ordered Vec and move light arrays into NBT instead of cloning
- treat fences/walls/bars/doors as light-transparent (slabs/stairs stay
  opaque due to shape occlusion)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Model light opacity as 0 (passes) / 1 (attenuates) / 15 (blocks) instead
of a transparent/opaque boolean, and reduce the skylight cast by 1 per
attenuating block. Fixes over-bright underwater columns and gives natural
soft shade under tree canopies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@louis-e louis-e force-pushed the fix/baked-chunk-lighting branch from 0a8cb3b to eeb06f7 Compare May 21, 2026 22:32
@louis-e louis-e requested a review from Copilot May 21, 2026 22:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread src/world_editor/java.rs
Comment on lines +466 to +470
queue: &mut std::collections::VecDeque<(usize, usize, usize, u8)>| {
let g = idx(nx, ny, nz);
if opacity[g] < 15 && light[g] < next {
light[g] = next;
queue.push_back((nx, ny, nz, next));
Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs Outdated
Baked lighting is only needed for off-disk LOD renderers (Voxy/Chunky);
vanilla relights on load. Gate it behind a `--bake-lighting` CLI flag and
a GUI toggle (translated into all locales), defaulting off so standard
generation keeps its prior speed and behavior (isLightOn=0, no light arrays).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Comment thread src/world_editor/java.rs
Comment thread src/world_editor/java.rs
Tests cover: baked chunks carry 2048-byte SkyLight/BlockLight per section
with isLightOn=1, the no-bake path omits them with isLightOn=0, and an
all-air chunk is fully skylit. Also give the Legacy terrain toggle the
same yellow accent as the other toggles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@louis-e louis-e merged commit ec0e945 into main May 21, 2026
3 checks passed
@louis-e louis-e deleted the fix/baked-chunk-lighting branch May 21, 2026 23:09
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.

2 participants