vec4b
On this page

vec4b

Function

vec4b groups 4 components into a vector. A single scalar broadcasts to every component.

Compare examples

Compare a broadcast with distinct components and a zero value. Each component retains its position.

Example 1vec4b(true)
truetruetruetrue
Components in this example
Result
[true,true,true,true]
Example 2vec4b(true, true, true, true)
truetruetruetrue
Components in this example
Result
[true,true,true,true]
Example 3vec4b(false)
falsefalsefalsefalse
Components in this example
Result
[false,false,false,false]

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 vectors to represent coordinates, directions, colours, or several independent values of the same type.

Inputs and limits

A constructor does not normalize a direction. Integer, boolean, and floating-point vectors have different component types; this compiler emulates f64 vectors in software.

For shader input rules and precision, consult WGSL and GLSL ES 3.00.

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Builds a vec4b from four bool scalars, a vec3b and a scalar, a vec2b and two scalars, broadcasts a single bool, or converts from a vec4 of a different element kind.

Syntax

declare function vec4b(): vec4b
declare function vec4b(x: bool, y: bool, z: bool, w: bool): vec4b
declare function vec4b(v: vec3b, w: bool): vec4b
declare function vec4b(v: vec2b, z: bool, w: bool): vec4b
declare function vec4b(x: bool, v: vec2b, w: bool): vec4b
declare function vec4b(x: bool, y: bool, v: vec2b): vec4b
declare function vec4b(x: bool, v: vec3b): vec4b
declare function vec4b(a: vec2b, b: vec2b): vec4b
declare function vec4b(scalar: bool): vec4b
declare function vec4b(v: vec4b): vec4b
declare function vec4b(v: vec4): vec4b
declare function vec4b(v: vec4i): vec4b
declare function vec4b(v: vec4u): vec4b

Parameters

Return value

vec4b

Description

A comparison of two vec4 values yields one.

See also

Edit this page Report a problem