---
title: "pack4x8unorm(): IR builder function in typeshade/core/ir"
description: "pack4x8unorm, an IR builder function in typeshade/core/ir. Pack a vec4<f32> into a u32 RGBA8."
url: https://typeshade.dev/api/pack4x8unorm/
language: en
---

# `pack4x8unorm()`

Function in Builtins

Pack a `vec4<f32>` into a `u32` RGBA8.

`import { pack4x8unorm } from 'typeshade/core/ir'`

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`pack4x8unorm()`](https://typeshade.dev/reference/functions/pack4x8unorm/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const pack4x8unorm: (v: ReadonlyNode<"vec4<f32>">) => Node<"u32">
```

## Parameters

**`v` `ReadonlyNode<'vec4<f32>'>`**

## Return value

`Node<'u32'>`

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `pack4x8unorm(v)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `(uint(floor(0.5 + clamp(v.x, 0.0, 1.0) * 255.0)) \| (uint(floor(0.5 + clamp(v.y, 0.0, 1.0) * 255.0)) << 8) \| (uint(floor(0.5 + clamp(v.z, 0.0, 1.0) * 255.0)) << 16) \| (uint(floor(0.5 + clamp(v.w, 0.0, 1.0) * 255.0)) << 24))`. |
| CPU oracle | Supported | Evaluated in `f64` by the oracle. |

## See also

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

## Source

[`src/core/ir/node.ts`, line 1631](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1631), at commit af54ddad5
