-
-
Notifications
You must be signed in to change notification settings - Fork 13
Fix sky light and block light calculation for schematics #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix sky light and block light calculation for schematics #39
Conversation
feat: add support for 1.21.6
Implementation of PaletteContainer, biome and dimension
| use tracing::warn; | ||
|
|
||
| /// Blocks that allow sky light to pass through (fully or partially transparent) | ||
| const TRANSPARENT_BLOCK_PATTERNS: &[&str] = &[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list of string IDs could be handled at compile time, where a build script would map this to smaller and more optimized InternalIds. Same for the LIGHT_EMITTING_BLOCKS const below.
For now, both have manageable amount of strings, so it is relatively fine. Comparing two strings is slower than two integers.
25ae43a to
f87644c
Compare
Quozul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update the docs to remove the line that says light is not supported.
crates/pico_structures/src/world.rs
Outdated
| let mut sky_light = 15u8; | ||
| for y in (0..total_height).rev() { | ||
| let pos = Coordinates::new(x, y, z); | ||
| let idx = get_index(x, y, z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are computing the index from the x,y,z coordinates, you could iterate over the index directly, to have only one loop. Similar below for the block_light_volume computation and at other places.
You could also probably merge both loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sky light loop needs to iterate top-down per column (to track when light gets blocked), so it can't be fully merged with block light. But I can simplify by iterating over columns and merging the inner work.
52619c7 to
7d9d14e
Compare
7d9d14e to
8f752f1
Compare
…abolcs05/PicoLimbo into feature/lighting-improvements
Add optimized light calculation using Starlight-inspired algorithm that processes both sky light and block light simultaneously. Uses parallel processing for initialization, pre-computed transparency data for better cache performance, and directional propagation tracking to avoid redundant checks. Includes helper methods for bounds checking and chunk indexing.
8f752f1 to
faba204
Compare
Fix sky light and block light calculation for schematics
Summary
This PR fixes broken lighting when loading schematic files into the world. Previously, lighting was not calculated correctly, resulting in areas being too bright or too dark.
Changes
Sky Light Calculation
Block Light Calculation
Light Propagation
Transparent Block Detection
Files Changed
Result
Schematics now display with natural-looking shadows and proper illumination from light sources.