summaryrefslogtreecommitdiff
path: root/src/client/game.cpp
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2022-03-26 16:58:26 +0100
committerGitHub <noreply@github.com>2022-03-26 16:58:26 +0100
commit0f25fa7af655b98fa401176a523f269c843d1943 (patch)
tree1fa8762f53941d6c1250c0c3a7dc6b8557995a40 /src/client/game.cpp
parent8d55702d139db739f8bf43eaa600f41446b29a16 (diff)
downloadminetest-0f25fa7af655b98fa401176a523f269c843d1943.tar.gz
minetest-0f25fa7af655b98fa401176a523f269c843d1943.tar.bz2
minetest-0f25fa7af655b98fa401176a523f269c843d1943.zip
Add API to control shadow intensity from the game/mod (#11944)
* Also Disable shadows when sun/moon is hidden. Fixes #11972.
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r--src/client/game.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 7450fb91c..edc69dcc2 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -4037,7 +4037,12 @@ void Game::updateShadows()
float in_timeofday = fmod(runData.time_of_day_smooth, 1.0f);
- float timeoftheday = fmod(getWickedTimeOfDay(in_timeofday) + 0.75f, 0.5f) + 0.25f;
+ float timeoftheday = getWickedTimeOfDay(in_timeofday);
+ bool is_day = timeoftheday > 0.25 && timeoftheday < 0.75;
+ bool is_shadow_visible = is_day ? sky->getSunVisible() : sky->getMoonVisible();
+ shadow->setShadowIntensity(is_shadow_visible ? client->getEnv().getLocalPlayer()->getLighting().shadow_intensity : 0.0f);
+
+ timeoftheday = fmod(timeoftheday + 0.75f, 0.5f) + 0.25f;
const float offset_constant = 10000.0f;
v3f light(0.0f, 0.0f, -1.0f);