diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-24 03:10:08 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-24 03:10:10 +0100 |
commit | 0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701 (patch) | |
tree | 987c196297c9be79dfc78875952965c4af2ebc28 /gfx | |
parent | Merge branch 'billboard-shadows' (diff) | |
download | ilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.tar.bz2 ilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.tar.xz ilt-0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701.zip |
Improve sun illumination based on angular size and astronomical twilight
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/lightDirection.cpp | 6 | ||||
-rw-r--r-- | gfx/lightDirection.h | 13 |
2 files changed, 15 insertions, 4 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)} { } diff --git a/gfx/lightDirection.h b/gfx/lightDirection.h index f1e1cc4..789830b 100644 --- a/gfx/lightDirection.h +++ b/gfx/lightDirection.h @@ -20,13 +20,20 @@ public: } [[nodiscard]] float - vertical() const noexcept + ambient() const noexcept { - return vert; + return amb; + } + + [[nodiscard]] float + directional() const noexcept + { + return dir; } private: Direction2D pos; Direction3D vec; - float vert; + float amb; + float dir; }; |