---
title: "vec4(): IR builder function in typeshade/core/ir, TypeShade"
description: "vec4, an IR builder function in typeshade/core/ir. A vec4<f32> constructor, WGSL-style: vec4."
url: https://typeshade.dev/api/vec4/
language: en
---

# `vec4()`

Function in Builtins

A `vec4<f32>` constructor, WGSL-style: `vec4`.

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

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

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

## Syntax

```ts
const vec4: (...a: NodeLike[]) => Node<"vec4<f32>">
```

## Parameters

**`...a` `NodeLike[]`**

## Return value

`Node<'vec4<f32>'>`

## Description

Bare number components lift to `f32`, so the common clip-space pattern `vec4(pos, 0, 1)` needs no `f32()` wrapper on the trailing arguments.

## Examples

### Example

```ts
import { fn, vec2, vec4, f32T } from 'typeshade/core/ir'

const clip = fn('clip', { pos: f32T }, ({ pos }) => vec4(vec2(pos, pos), 0, 1))
```

## In the guide

- [Your first shader](https://typeshade.dev/guide/internals/your-first-shader/)
- [Values and mutation](https://typeshade.dev/guide/internals/values-and-mutation/)
- [Functions and entry points](https://typeshade.dev/guide/internals/functions-and-entry-points/)
- [Layouts and resources](https://typeshade.dev/guide/internals/layouts-and-resources/)
- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)
- [Migrating a GLSL shader](https://typeshade.dev/guide/internals/migrating-a-glsl-shader/)

## See also

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

## Source

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