feather
feather copied to clipboard
Lighting support
Lighting will need to be calculated each time a block is updated.
For reference:
- https://minecraft.gamepedia.com/Light
- https://en.wikipedia.org/wiki/Flood_fill
Ideally, this would be done multithreaded on a per-chunk basis.
I'm not sure how to correctly handle block updates. We could recalculate the light for the entire chunk, but this is incredibly inefficient.
Just stumbled over this project, looks awesome! I thought i'd try to play around with this a bit to learn about spec.
What about a System which goes through all BlockUpdateEvents and recalculates lighting in every chunk which has been updated?
Just stumbled over this project, looks awesome! I thought i'd try to play around with this a bit to learn about spec.
What about a
Systemwhich goes through allBlockUpdateEvents and recalculates lighting in every chunk which has been updated?
Lighting would be stored in the Chunk, as it is in vanilla, in two compact arrays. See https://wiki.vg/index.php?title=Chunk_Format&diff=14678&oldid=14646#Chunk_Section_structure.
As a starting point, going through BlockUpdateEvents and recalculating the entire chunk would be fine. We would want to optimize the algorithm so that only blocks affected by light updates are recalculated, and not the entire chunk.
that sounds reasonable.
I think a good approach would be to store all light sources in each chunk. When a light source is placed/destroyed, we just increase/decrease the light-level of surrounding blocks. When a normal block is placed/broken though, we'll have to go through all light sources (which are close) and recalculate their light. What do you think?
For this it'd be nice to create a struct similar to ChunkMap which just stores the light sources, soemthing like HashMap<ChunkPosition, Vec<(BlockPosition, LightLevel)>>.
@NyxCode Yes, that will work. To start, we should probably resolve #103 so that existing lighting data is loaded. This will also involve adding the light storage in Chunk.
Glad to see some interest in this project!
yeah, i'll look at that first! I don't have a lot of time, but this project looks great! Is there a place for discussions/questions except github issues? maybe a discord server?
Is there a place for discussions/questions except github issues? maybe a discord server?
Well, the project didn't have any publicity until it ballooned yesterday, so we don't really have a community or discussion place. I could make a Discord server, but given the early state of the project, I'm not sure if there's a need yet.
:D the post on the rust subreddit, huh? I mean, it's your call, but I could imagine that a place for discussion on the development would be usefull.
I mean, it's your call, but I could imagine that a place for discussion on the development would be usefull.
I guess I agree; here's the Discord server. https://discord.gg/4eYmK69