From ff88911f93ef0df2d0ae8f9a7cd2bdcf780c4753 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Fri, 11 May 2018 12:26:03 +0200 Subject: [PATCH] Protected procedural skyboxes from NaNs and negative values returned by procedural shader --- libraries/graphics/src/graphics/skybox.slf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/graphics/src/graphics/skybox.slf b/libraries/graphics/src/graphics/skybox.slf index 7b25e36af7..153e73b9ef 100755 --- a/libraries/graphics/src/graphics/skybox.slf +++ b/libraries/graphics/src/graphics/skybox.slf @@ -35,8 +35,11 @@ void main(void) { #ifdef PROCEDURAL vec3 color = getSkyboxColor(); - // Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline - color = pow(color, vec3(2.2)); + // Protect from NaNs and negative values + color = mix(color, vec3(0), isnan(color)); + color = max(color, vec3(0)); + // Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline + color = pow(color, vec3(2.2)); _fragColor = vec4(color, 0.0); // FIXME: scribe does not yet scrub out else statements