mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix node-nodebox lighting difference in direct sunlight (#7061)
This commit is contained in:
parent
b1c0e9953f
commit
0358ae789a
3 changed files with 71 additions and 29 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue