---
title: "fieldSlope"
description: "The direction the shape's distance grows in: a 2D vector pointing outward at this pixel."
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#L419"
---

# fieldSlope

The direction the shape's distance grows in: a 2D vector pointing outward at this pixel.

```ts
fieldSlope(field: SurfaceField, eps: number = 0.01): Expr
```

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

Its length is about 1 on a flat shape. `eps` is the tap step (default 0.01) and must match the stencil step.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `field` | `SurfaceField` |  |
| `eps` | `number` | Optional. Default `0.01`. |

## Example

```ts
const grad = fieldSlope(field)
```

## See also

- [`nearestEdge`](/docs/primitives/materials/nearestedge) — The closest point on the shape's edge to this pixel, and the outward normal there.
- [`geometricNormal`](/docs/primitives/materials/geometricnormal) — The surface normal of the shape, whichever kind of shape is active.
- [`tiltAlong`](/docs/primitives/materials/tiltalong) — Tilts a normal along one 2D direction by a slope amount.

## Used by

[Crystal](/docs/components/crystal), [Frost](/docs/components/frost), [Holographic](/docs/components/holographic), [Irradiance](/docs/components/irradiance), [Plastic](/docs/components/plastic), [Water](/docs/components/water)