GLSL built-in function
isnan()
Detects NaN component-wise.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
genBType isnan(genType x)genType means float / vec2 / vec3 / vec4; matching placeholders use the same type.
Parameters
- x
- Input value or left-hand vector
Return value
A bool or boolean vector marking NaN components with true and all numeric values with false.
Live example
Edit the code and the preview updates as you type.
What isnan does
Detects NaN component-wise.
Read the preview
The finite coordinate in isnan(x) is never NaN, so the green line stays at y = 0. Substituting x*0.0 keeps the result false because zero is a valid number.
Core call
float(isnan(x));
Equality cannot detect NaN. This example supplies finite input, so every test is false.
Experiment
Use 1.0-float(isnan(x)) instead of float(isnan(x)). The line moves to y = 1, showing that all inputs in this coordinate demo pass the not-NaN check.