---
title: "fdSlope"
description: "The value and slope of any field at a point: `value`, `dx` and `dy`."
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#L997"
---

# fdSlope

The value and slope of any field at a point: `value`, `dx` and `dy`.

```ts
fdSlope(sampleAt: (p: Expr) => Expr, p: Expr, eps: number, hint: string = 'fd'): {value: Expr; dx: Expr; dy: Expr}
```

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

`sampleAt` is the field as a function of a 2D point, `eps` the tap distance in that point's units (a few thousandths in uv). The bridge from a height field to a normal: feed `dx` and `dy` to `nudgeNormal`.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `sampleAt` | `(p: Expr) => Expr` |  |
| `p` | `Expr` |  |
| `eps` | `number` |  |
| `hint` | `string` | Optional. Default `'fd'`. |

## Example

```ts
const relief = fdSlope((at) => heightField(params, at), uv, 0.0035)
```

> **Tip.** Three taps of the field per pixel. Keep the field cheap or `share` it.

## See also

- [`nudgeNormal`](/docs/primitives/materials/nudgenormal) — Tilts a normal by a slope in x and y, turning a height field into relief.
- [`perlinSlope`](/docs/primitives/materials/perlinslope) — The slope of smooth noise at a point, for wavy or molten relief.
- [`cellNoiseAt`](/docs/primitives/materials/cellnoiseat) — Cellular noise at a 2D point: 0 at each cell's seed point, rising toward the cell walls.

## Used by

[Crystal](/docs/components/crystal), [Satin](/docs/components/satin)