valoeghese / 2fc0f18

Not-So-Bad-Anymore block game with more of an RPG vibe. Inspired by Minecraft and Cube World
Other
2 stars 0 forks source link

Sky and Block Lighting #8

Closed valoeghese closed 4 years ago

valoeghese commented 4 years ago

I propose two byte arrays in each chunk for sky and block lighting. Lighting is calculated as part of the "population" phase of a chunk, after world gen population occurs. Light emitting blocks are limited to 15, not to be limited to minecraft, but to limit the amount that light can overflow into neighbouring chunks.

Sky light will be simple at first: [0~15] above the ground based on time of day, 0 below ground. Block light will also have a simple propagation algorithm initially. All opaque blocks will completely block light. The actual light at a position is Math.max(sky, block). When a light source is removed, the entire chunk's light is recalculated, and any neighbouring populating (not generating) chunks have their light recalculated.

As lighting is populated, this means it will be stored with the chunk. A new ByteArrayDataSection will be used for lighting, and will store in the format sky, block, in the same order as tiles.

We use the current min and max global lighting as the min and max represented by 0 and 15. Sky lighting will still be calculated the same.

valoeghese commented 4 years ago

I did it slightly differently. Closed by merge of lighting branch.