---
title: "fill: shader function examples, uses and input limits"
description: "Fill constructs a fixed-size array by repeating one value. Use it for initializing a short array to a known value. Specify the element type and length."
url: https://typeshade.dev/reference/functions/fill/
language: en
---

# `fill`

Function

Fill constructs a fixed-size array by repeating one value.

## Compare examples

A scalar fills every element with that scalar. A vector fills every element with that vector.

**Example 1`fill<f32, 3>(0.)`**

**Result**

`[0, 0, 0]`

**Example 2`fill<f32, 3>(2.)`**

**Result**

`[2, 2, 2]`

**Example 3`fill<vec2, 2>(vec2(1., 2.))`**

**Result**

`[[1, 2], [1, 2]]`

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 initializing a short array to a known value.

## Inputs and limits

Specify the element type and length. It creates a value, not a storage-buffer allocation or a host-to-GPU upload.

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

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

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

Creates an `array<T, N>` where every element is the given value; requires type arguments `fill<T, N>(value)`.

## Syntax

```ts
declare function fill<T, N extends number>(value: T): array<T, N>
```

A `number` in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

`type f32 = number & { readonly [f32Tag]?: true }`

A `number` you write as a type is inferred from its uses, and `f32`, `i32` and `u32` fix a width; [the TypeScript constructs page](https://typeshade.dev/guide/language/from-typescript/) carries that row with the compiler's emit.

## Parameters

- `value` `T`

## Return value

`array<T, N>`

## See also

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