Protected procedural skyboxes from NaNs and negative values returned by procedural shader

This commit is contained in:
Olivier Prat 2018-05-11 12:26:03 +02:00
parent 9e462e777c
commit ff88911f93

View file

@ -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