summary refs log tree commit diff
path: root/src/World/Generation/Lighting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/Generation/Lighting.cpp')
-rw-r--r--src/World/Generation/Lighting.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/World/Generation/Lighting.cpp b/src/World/Generation/Lighting.cpp
new file mode 100644
index 0000000..8df6e2a
--- /dev/null
+++ b/src/World/Generation/Lighting.cpp
@@ -0,0 +1,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;
+            }
+        }
+    }
+}
+
+}