Fix dark chunks - addresses #2029 and #1899, prepares for fix of #2002, #2024, and #2035 #2060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
It is possible for chunks to have no sky light data whatsoever.
This can happen for a number of reasons (see also: #2029, #1899), but in particular, all worlds that have been optimized with
--forceUpgrade
in 1.19 will be completely dark until chunks are loaded ingame.Also, Minecraft sometimes saves chunks with incomplete light data. These chunks only contain "spillover" light from neighboring chunks, but the sky light from the chunk itself is not taken into account. It is common for these chunks to appear on "version borders", and they are almost completely dark. Screenshots of an example at two different zoom levels:
Overview of contents
This PR addresses this issue in two steps:
Also, in order to cleanly implement this change, I did a bit of refactoring.
Detailed reasoning for the decision to check chunks for a block with full skylight
Two observations:
These observations together mean that:
In practice, on my test world of slightly over 5000 tiles, a pure python PoC implementation of this heuristic bumped the runtime from 8:35 to 8:50, and the numpy implementation somehow managed to finish rendering faster, in 8:06. While that is based on only one run per implementation, I think it's safe to say that this change does not significantly affect performance.
And in any case, if it is deemed preferable not to do that, we can just yeet the second commit.
Reverse dependency to rendering 1.18+ chunks properly again
This issue came up in #2051, my first attempt at fixing the rendering of pre-1.18 worlds that were loaded in Minecraft 1.18 or higher. Since these chunks turn out completely dark if they were optimized but not loaded in 1.19 (see above), it makes sense to first fix this lighting issue before making these chunks render.
@cliffmeyers and I agreed to split the change into two PRs to avoid scope creep, so I'd like to get this merged first.