Skip to content

Chunk light calculation

Bruno Ploumhans edited this page Jun 23, 2020 · 1 revision

Light updates are quite expensive! They are computed on a separate thread on the server side. It does not matter that the client might have to wait a little for updated light levels.

There two sources of light: blocks that emit light (torches, etc...) and the sun. When the day/night cycle will be implemented, it will be important that the two kinds of lights are stored separately.

Light emitted by blocks

NYI!

Light emitted by the sun

We store the highest opaque block in each column (x, z), and we consider that all blocks above are sources of light. When we compute the light levels for a chunk, we find all sources in the current chunk and the relevant part of the 26 adjacent chunks. We then propagate the light levels using a BFS. This happens in the function compute_light in common/src/light/mod.rs.

Whenever a chunk is updated, we need to update the highest opaque block and mark the whole 3x3 column for chunk updates.

Clone this wiki locally