---
title: "cosineRainbow"
description: "A smooth rainbow color from a value that wraps every 1."
group: "light"
groupTitle: "Noise, light & materials"
categoryId: "materials"
categorySlug: "materials"
categoryTitle: "Materials & surfaces"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/materials.ts#L961"
---

# cosineRainbow

A smooth rainbow color from a value that wraps every 1.

```ts
cosineRainbow(t: Expr, phases: [number, number, number]): Expr
```

Import `materials` from `shaders/std` and use `materials.cosineRainbow`.

`phases` offset the red, green and blue cycles; `[0, 1/3, 2/3]` is the full spectrum. The color behind holographic foil and thin-film iridescence.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `t` | `Expr` |  |
| `phases` | `[number, number, number]` |  |

## Example

```ts
const rgb = cosineRainbow(mul(grazing, 3), [0, 1 / 3, 2 / 3])
```

## See also

- [`tintRamp`](/docs/primitives/materials/tintramp) — Maps a lighting value (0 dark, 1 light) onto two colors.

## Used by

[Holographic](/docs/components/holographic)