diff options
author | Vitaliy <silverunicorn2011@yandex.ru> | 2018-03-17 12:10:16 +0300 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-03-17 10:10:16 +0100 |
commit | 0358ae789a6aa5c161c3b9017651b7d2c2f28fd8 (patch) | |
tree | eb01dfae5b0dd4d3d73208397c8f64f72735fd8a /src/mapblock_mesh.cpp | |
parent | b1c0e9953f46837b7e6ffe418a89ff7627e88497 (diff) | |
download | minetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.tar.gz minetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.tar.bz2 minetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.zip |
Fix node-nodebox lighting difference in direct sunlight (#7061)
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r-- | src/mapblock_mesh.cpp | 13 |
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) { |