ACBob / VoxelThingYeah

Voxel Game Engine
1 stars 1 forks source link

Lighting engine ideas #29

Open ACBob opened 2 years ago

ACBob commented 2 years ago

Instead of having lighting handled by the chunk, move responsibility to the World. The world handles all of the lighting as it knows about every chunk.

We start sunlight in a kind-of odd way. At the top of every chunk. If there is no chunk above us, assume every block at the top has full sunlight and no artificial light. If there's a chunk above us, use the sunlight value of the air.

Sunlight propagation should be handled thusly; at the top of every chunk, loop down until we hit a block that does not allow sunlight to propagate. after that, set the sunlight value of the block to 0.

These should be different steps! If a non-solid block (i.e not a cube) is broken, don't try to re-calculate sunlight. If it is, make sure there's even a little bit of sunlight. This should loop down to the bottom of the loaded chunks.

lighting data gets saved to the disk along with worlds (important for #8), the server also calculates sunlight and sends it to the client.

ACBob commented 2 years ago

The data gets stored in the chunk's mesh for rendering, so a lighting update == a mesh update (perhaps a special type of one, that only updates lighting?)

Maybe use a shader uniform, storing it in each chunk and yanking it out when we need??