aboutsummaryrefslogtreecommitdiff
path: root/src/content_mapblock.h
diff options
context:
space:
mode:
authorVitaliy <silverunicorn2011@yandex.ru>2018-03-17 12:10:16 +0300
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-03-17 10:10:16 +0100
commit0358ae789a6aa5c161c3b9017651b7d2c2f28fd8 (patch)
treeeb01dfae5b0dd4d3d73208397c8f64f72735fd8a /src/content_mapblock.h
parentb1c0e9953f46837b7e6ffe418a89ff7627e88497 (diff)
downloadminetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.tar.gz
minetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.tar.bz2
minetest-0358ae789a6aa5c161c3b9017651b7d2c2f28fd8.zip
Fix node-nodebox lighting difference in direct sunlight (#7061)
Diffstat (limited to 'src/content_mapblock.h')
-rw-r--r--src/content_mapblock.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/content_mapblock.h b/src/content_mapblock.h
index 7b90ce4b9..97947cdbe 100644
--- a/src/content_mapblock.h
+++ b/src/content_mapblock.h
@@ -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);