---
title: "refract"
description: "The direction `i` bent through 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#L400"
---

# refract

The direction `i` bent through a surface with unit normal `n`.

```ts
refract(i: Val, n: Val, eta: Val): Expr
```

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

`eta` is the ratio of refractive indices, about 0.66 going from air into glass.

## Parameters

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

## Example

```ts
const bent = refract(viewDir, normal, 0.66)
```

## See also

- [`reflect`](/docs/primitives/math/reflect) — The direction `i` bounced off a surface with unit normal `n`.