summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-12-11 00:12:38 +0100
committerGitHub <noreply@github.com>2017-12-11 00:12:38 +0100
commitdcc5e21b35efec977539c8e0f5615a30a5fff581 (patch)
treed17abedbeecc001bde6de29da16197152c28cdc2
parent50fab3dc1ae564f5cfeccf68835b6d67b38980cb (diff)
parent95056ca9139cafa34619957711e2b739c9fc8672 (diff)
Merge pull request #14520 from Smjert/fix/11247/skybox
Fix skybox generation imprecision with Clang
-rw-r--r--scene/resources/sky_box.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 2ef20f67f5..a2c3f1f111 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -180,7 +180,7 @@ Ref<Image> ProceduralSky::_generate_sky() {
normal.normalize();
- float v_angle = Math::acos(normal.y);
+ float v_angle = Math::acos(CLAMP(normal.y, -1.0, 1.0));
Color color;
@@ -193,7 +193,7 @@ Ref<Image> ProceduralSky::_generate_sky() {
float c = v_angle / (Math_PI * 0.5);
color = sky_horizon_linear.linear_interpolate(sky_top_linear, Math::ease(1.0 - c, sky_curve));
- float sun_angle = Math::rad2deg(Math::acos(sun.dot(normal)));
+ float sun_angle = Math::rad2deg(Math::acos(CLAMP(sun.dot(normal), -1.0, 1.0)));
if (sun_angle < sun_angle_min) {
color = color.blend(sun_color);