diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-06 12:48:40 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-06 14:03:33 +0100 |
commit | 10998a8302b3d7651b4afc046311961eb2dea2c8 (patch) | |
tree | 1b58847ae898f9d3c7fa807bfcaa4b4103d6f35f /game/environment.cpp | |
parent | Add LightDirection class (diff) | |
download | ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.bz2 ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.xz ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.zip |
Use LightDirection for calculating/passing all light dir components
Diffstat (limited to 'game/environment.cpp')
-rw-r--r-- | game/environment.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/game/environment.cpp b/game/environment.cpp index 19aad84..5aa1f09 100644 --- a/game/environment.cpp +++ b/game/environment.cpp @@ -1,4 +1,5 @@ #include "environment.h" +#include "gfx/lightDirection.h" #include <chronology.h> #include <gfx/gl/sceneRenderer.h> @@ -16,14 +17,12 @@ Environment::render(const SceneRenderer & renderer, const SceneProvider & scene) constexpr RGB baseAmbient {0.1F}, baseDirectional {0.0F}; constexpr RGB relativeAmbient {0.3F, 0.3F, 0.4F}, relativeDirectional {0.6F, 0.6F, 0.5F}; - const auto sunPos = getSunPos({}, worldTime); - const auto sunDir = (glm::mat3 {rotate_yp({sunPos.y + pi, sunPos.x})} * north); - const auto vertical = -std::min(0.F, sunDir.z - 0.1F); - const auto ambient = baseAmbient + relativeAmbient * vertical; - const auto directional = baseDirectional + relativeDirectional * vertical; + const LightDirection sunPos = getSunPos({}, worldTime); + const auto ambient = baseAmbient + relativeAmbient * sunPos.vertical(); + const auto directional = baseDirectional + relativeDirectional * sunPos.vertical(); renderer.setAmbientLight(ambient); - renderer.setDirectionalLight(directional, sunDir, scene); + renderer.setDirectionalLight(directional, sunPos, scene); } // Based on the C++ code published at https://www.psa.es/sdg/sunpos.htm |