blob: 8df6e2a0024348558eaf92aa73bf06442cb50fec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "Lighting.hpp"
namespace MC::World::Generation::Lighting {
void light_chunk(Chunk& chunk, ChunkNeighbors& _) {
for (UInt x = 0; x < Chunk::Width; x++) {
for (UInt z = 0; z < Chunk::Width; z++) {
U8 current_light_exposure = LightSun;
for (UInt y = Chunk::Height - 1; y != 0; y--) {
auto& block = chunk.at(x, y, z);
if (!block.type.is_translucent()) break;
current_light_exposure = (Real)current_light_exposure * (1 - block.type.opacity());
block.light = current_light_exposure;
}
}
}
}
}
|