1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-10 20:05:26 +01:00

Fix node-nodebox lighting difference in direct sunlight (#7061)

This commit is contained in:
Vitaliy
2018-03-17 12:10:16 +03:00
committed by Loïc Blot
parent b1c0e9953f
commit 0358ae789a
3 changed files with 71 additions and 29 deletions

View File

@@ -26,21 +26,36 @@ struct MeshMakeData;
struct MeshCollector;
struct LightPair {
u8 lightA;
u8 lightB;
u8 lightDay;
u8 lightNight;
LightPair() = default;
explicit LightPair(u16 value) : lightA(value & 0xff), lightB(value >> 8) {}
LightPair(u8 valueA, u8 valueB) : lightA(valueA), lightB(valueB) {}
explicit LightPair(u16 value) : lightDay(value & 0xff), lightNight(value >> 8) {}
LightPair(u8 valueA, u8 valueB) : lightDay(valueA), lightNight(valueB) {}
LightPair(float valueA, float valueB) :
lightA(core::clamp(core::round32(valueA), 0, 255)),
lightB(core::clamp(core::round32(valueB), 0, 255)) {}
operator u16() const { return lightA | lightB << 8; }
lightDay(core::clamp(core::round32(valueA), 0, 255)),
lightNight(core::clamp(core::round32(valueB), 0, 255)) {}
operator u16() const { return lightDay | lightNight << 8; }
};
struct LightInfo {
float light_day;
float light_night;
float light_boosted;
LightPair getPair(float sunlight_boost = 0.0) const
{
return LightPair(
(1 - sunlight_boost) * light_day
+ sunlight_boost * light_boosted,
light_night);
}
};
struct LightFrame {
f32 lightsA[8];
f32 lightsB[8];
f32 lightsDay[8];
f32 lightsNight[8];
bool sunlight[8];
};
class MapblockMeshGenerator
@@ -69,7 +84,7 @@ public:
// lighting
void getSmoothLightFrame();
LightPair blendLight(const v3f &vertex_pos);
LightInfo blendLight(const v3f &vertex_pos);
video::SColor blendLightColor(const v3f &vertex_pos);
video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
@@ -85,7 +100,7 @@ public:
// cuboid drawing!
void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
const LightPair *lights , const f32 *txc);
const LightInfo *lights , const f32 *txc);
void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
void drawAutoLightedCuboid(aabb3f box, const f32 *txc = NULL,
TileSpec *tiles = NULL, int tile_count = 0);