any
Function
Any is true when at least one component of a boolean or a boolean vector is true.
Compare examples
The result is true if any component is true. It is false only when every component is false.
Example 1any(vec2b(false, false))
falsefalse - Result
false
Example 2any(vec2b(false, true))
falsetrue - Result
true
Example 3any(vec2b(true, true))
truetrue - Result
true
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it for detecting whether a condition occurs anywhere.
Inputs and limits
A per-component comparison creates a boolean vector; any reduces it to a single boolean.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
- WGSL
any(a)- GLSL ES 3.00
any(a)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Whether any component of a vector of bools is true: any(a < b).
Syntax
declare function any(a0: bool): booldeclare function any<V extends vec2b | vec3b | vec4b>(a0: V): (bool)declare function any(v: bool | BoolVec): boolA signature may name a type the ambient file declares for its own use. These are those declarations.
BoolVectype BoolVec = vec2b | vec3b | vec4b
Parameters
Return value
Description
A scalar bool passes through. Over an array, write xs.some((x) => ...).
Targets
- WGSL
-
any(a) - GLSL ES 3.00
-
any(a)