summaryrefslogtreecommitdiff
path: root/src/mapblock_mesh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r--src/mapblock_mesh.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index bdf791c0b..6a94e78df 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -196,6 +196,7 @@ static u16 getSmoothLightCombined(const v3s16 &p,
u8 light_source_max = 0;
u16 light_day = 0;
u16 light_night = 0;
+ bool direct_sunlight = false;
auto add_node = [&] (u8 i, bool obstructed = false) -> bool {
if (obstructed) {
@@ -210,8 +211,12 @@ static u16 getSmoothLightCombined(const v3s16 &p,
light_source_max = f.light_source;
// Check f.solidness because fast-style leaves look better this way
if (f.param_type == CPT_LIGHT && f.solidness != 2) {
- light_day += decode_light(n.getLightNoChecks(LIGHTBANK_DAY, &f));
- light_night += decode_light(n.getLightNoChecks(LIGHTBANK_NIGHT, &f));
+ u8 light_level_day = n.getLightNoChecks(LIGHTBANK_DAY, &f);
+ u8 light_level_night = n.getLightNoChecks(LIGHTBANK_NIGHT, &f);
+ if (light_level_day == LIGHT_SUN)
+ direct_sunlight = true;
+ light_day += decode_light(light_level_day);
+ light_night += decode_light(light_level_night);
light_count++;
} else {
ambient_occlusion++;
@@ -243,6 +248,10 @@ static u16 getSmoothLightCombined(const v3s16 &p,
light_night /= light_count;
}
+ // boost direct sunlight, if any
+ if (direct_sunlight)
+ light_day = 0xFF;
+
// Boost brightness around light sources
bool skip_ambient_occlusion_day = false;
if (decode_light(light_source_max) >= light_day) {