From 0889f3f6d7b96c6f6d186ca8fa7f4e9e0ec9c701 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 24 Oct 2024 03:10:08 +0100 Subject: Improve sun illumination based on angular size and astronomical twilight --- gfx/lightDirection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gfx/lightDirection.cpp') 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)} { } -- cgit v1.2.3