any
On this page

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
Components in this example
Result
false
Example 2any(vec2b(false, true))
falsetrue
Components in this example
Result
true
Example 3any(vec2b(true, true))
truetrue
Components in this example
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.

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): bool
declare function any<V extends vec2b | vec3b | vec4b>(a0: V): (bool)
declare function any(v: bool | BoolVec): bool

A signature may name a type the ambient file declares for its own use. These are those declarations.

BoolVec
type BoolVec = vec2b | vec3b | vec4b

Parameters

Return value

bool(bool)

Description

A scalar bool passes through. Over an array, write xs.some((x) => ...).

Targets

WGSL
any(a)
GLSL ES 3.00
any(a)

Examples

See also

Edit this page Report a problem