GLSL built-in function
any()
Returns true when at least one component is true.
Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Fragment
Syntax
bool any(bvec2 x)
bool any(bvec3 x)
bool any(bvec4 x)Parameters
- x
- Input value or left-hand vector
Return value
One bool: false only if every component of x is false.
Live example
Edit the code and the preview updates as you type.
What any does
Returns true when at least one component is true.
Read the preview
any(greaterThan(abs(vec2(x,y)),vec2(0.5))) colors the area outside a central square. Raise the bound to vec2(0.75) and the central unselected square grows.
Core call
float(any(greaterThan(abs(vec2(x,y)),vec2(0.5))));
Use any for an out-of-bounds test; use all when every condition must hold.
Experiment
Replace vec2(0.5) with vec2(0.25,0.75) in greaterThan. The area where neither comparison succeeds becomes a narrow, tall rectangle.