---
title: "reflect"
description: "The direction `i` bounced off a surface with unit normal `n`."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L388"
---

# reflect

The direction `i` bounced off a surface with unit normal `n`.

```ts
reflect(i: Val, n: Val): Expr
```

Import `math` from `shaders/std` and use `math.reflect`.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `i` | `Val` |  |
| `n` | `Val` |  |

## Example

```ts
const bounce = reflect(viewDir, normal)
```

## See also

- [`refract`](/docs/primitives/math/refract) — The direction `i` bent through a surface with unit normal `n`.
- [`normalize`](/docs/primitives/math/normalize) — The vector scaled to length 1.