diff options
author | Stefano Bonicatti <smjert@gmail.com> | 2017-12-10 19:48:47 +0100 |
---|---|---|
committer | Stefano Bonicatti <smjert@gmail.com> | 2017-12-10 19:56:45 +0100 |
commit | 95056ca9139cafa34619957711e2b739c9fc8672 (patch) | |
tree | 57cc76976f110dcf1fe2f722d6b906e1152ecbf0 | |
parent | 523237943cff1bb1b2b5e85289bb89455856437a (diff) |
Fix skybox generation imprecision with Clang
The bug generated a "blue circle" at the bottom end of the y axis,
and probably one too at the other end.
This is caused by a normalization of a vector which results in its y component
to be sometimes > 1.0 or < -1.0 in Clang.
This value is then used with acos(), which returns NaN.
Fixes #11247
-rw-r--r-- | scene/resources/sky_box.cpp | 4 |
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); |