---
title: "vec3b: shader function examples, uses and input limits"
description: "vec3b groups 3 components into a vector. A single scalar broadcasts to every component."
url: https://typeshade.dev/reference/functions/vec3b/
language: en
---

# `vec3b`

Function

`vec3b` groups 3 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 1`vec3b(true)`**

`true` `true` `true`

Components in this example

**Result**

`[true,true,true]`

**Example 2`vec3b(true, true, true)`**

`true` `true` `true`

Components in this example

**Result**

`[true,true,true]`

**Example 3`vec3b(false)`**

`false` `false` `false`

Components in this example

**Result**

`[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](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`length`](https://typeshade.dev/reference/functions/length/)
- [`normalize`](https://typeshade.dev/reference/functions/normalize/)
- [`dot`](https://typeshade.dev/reference/functions/dot/)

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

Builds a `vec3b` from three `bool` scalars, a `vec2b` and a scalar, broadcasts a single `bool`, or converts from a `vec3` of a different element kind.

## Syntax

```ts
declare function vec3b(): vec3b
declare function vec3b(x: bool, y: bool, z: bool): vec3b
declare function vec3b(v: vec2b, z: bool): vec3b
declare function vec3b(x: bool, v: vec2b): vec3b
declare function vec3b(scalar: bool): vec3b
declare function vec3b(v: vec3b): vec3b
declare function vec3b(v: vec3): vec3b
declare function vec3b(v: vec3i): vec3b
declare function vec3b(v: vec3u): vec3b
```

## Parameters

- `x` optional `bool`
- `v` optional `vec2b``vec3b``vec3``vec3i``vec3u`
- `scalar` optional `bool`
- `y` optional `bool`
- `z` optional `bool`

## Return value

`vec3b`

## Description

A comparison of two `vec3` values yields one.

## Examples

- [`gallery/bool-select/bool-select.shade.ts`](https://typeshade.dev/guide/examples/bool-select/)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
