This is based on the question: Best way to detect NaN's in OpenGL shaders
Standard GLSL defines isnan() and isinf() functions for detection. OpenGL ES 2.0 shading language doesn't. How can I deal with NaNs and Infs nevertheless?
You can check for NaN via a condition that will only be true for NaN:
bool isNan(float val)
{
return (val <= 0.0 || 0.0 <= val) ? false : true;
}
isinf
is a bit more difficult. There is no mechanism to convert the float into its integer representation and play with the bits. So you'll have to compare it against a suitably large number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With