summaryrefslogtreecommitdiff
path: root/gfx/lightDirection.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-10-24 03:10:08 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-10-24 03:10:10 +0100
commit0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701 (patch)
tree987c196297c9be79dfc78875952965c4af2ebc28 /gfx/lightDirection.cpp
parentMerge branch 'billboard-shadows' (diff)
downloadilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.tar.bz2
ilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.tar.xz
ilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.zip
Improve sun illumination based on angular size and astronomical twilight
Diffstat (limited to 'gfx/lightDirection.cpp')
-rw-r--r--gfx/lightDirection.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/gfx/lightDirection.cpp b/gfx/lightDirection.cpp
index 6d7d1ea..3932872 100644
--- a/gfx/lightDirection.cpp
+++ b/gfx/lightDirection.cpp
@@ -1,8 +1,12 @@
#include "lightDirection.h"
#include "maths.h"
+constexpr auto ASTRONOMICAL_TWILIGHT = 18.0_degrees;
+constexpr auto SUN_ANGLUAR_SIZE = 0.5_degrees;
+
LightDirection::LightDirection(const Direction2D sunPos) :
pos {sunPos}, vec {glm::mat3 {rotate_yp(pi + sunPos.x, -sunPos.y)} * north},
- vert {-glm::clamp(-1.F, 0.F, vec.z - 0.1F)}
+ amb {glm::clamp(sunPos.y + ASTRONOMICAL_TWILIGHT, 0.F, 1.F)},
+ dir {glm::clamp(sunPos.y + SUN_ANGLUAR_SIZE, 0.F, 1.F)}
{
}