summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/lightDirection.cpp6
-rw-r--r--gfx/lightDirection.h13
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;
};