GLSL built-in function
isinf()
Detects positive or negative infinity component-wise.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
genBType isinf(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: true for positive or negative infinity, false for other values.
Live example
Edit the code and the preview updates as you type.
What isinf does
Detects positive or negative infinity component-wise.
Read the preview
Every x in isinf(x) is finite, so the plotted result is zero. Replace x with x*1000.0: larger finite values still leave the background unchanged.
Core call
float(isinf(x));
A large finite value is not infinity; a divide-by-zero test is not portable.
Experiment
Change float(isinf(x)) to 1.0-float(isinf(x)). The result becomes 1 everywhere, displaying the complementary finite-value test without relying on division by zero.