---
title: "dpdxCoarse / dFdx: WGSL and GLSL function guide"
description: "A screen-space derivative estimates how a value changes between neighbouring fragment invocations along the x axis."
url: https://typeshade.dev/reference/functions/dpdxCoarse/
language: en
---

# `dpdxCoarse`

Function

A screen-space derivative estimates how a value changes between neighbouring fragment invocations along the x axis.

**Related names in other languages**

These related operations can differ in arguments, support, and semantics. The foreign names are not accepted TypeShade aliases. Check the target forms and restrictions.

- GLSL: `dFdx`

[Targets](https://typeshade.dev/reference/functions/dpdxCoarse/#targets)

## Compare examples

Compare a constant field with a linear ramp. The result measures change per pixel, not the field value.

**Model assumptions**`f(px, py) = a × px + b × py + c`

**Example 1`a = 0; b = 0; c = 5`**

`5` `5` `5` `5`

Field values at neighbouring pixels. The lower row adds a vertical pixel step.

**Result**

`0`

**Example 2`a = 0.25; b = 0; c = 0`**

`0` `0.25` `0` `0.25`

Field values at neighbouring pixels. The lower row adds a vertical pixel step.

**Result**

`0.25`

**Example 3`a = 0.25; b = -0.5; c = 1`**

`1` `1.25` `0.5` `0.75`

Field values at neighbouring pixels. The lower row adds a vertical pixel step.

**Result**

`0.25`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it to estimate a pixel footprint, recover a surface gradient, or control filtering.

## Inputs and limits

The model uses an affine field, so coarse and fine estimates agree. Nonlinear fields can differ. Derivatives require fragment-stage uniform control flow; GLSL ES chooses its own granularity.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`dpdx`](https://typeshade.dev/reference/functions/dpdx/)
- [`dpdy`](https://typeshade.dev/reference/functions/dpdy/)
- [`fwidth`](https://typeshade.dev/reference/functions/fwidth/)

**WGSL**

`dpdxCoarse(a)`

**GLSL ES 3.00**

`dFdx(a)`

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

The partial derivative of `x` with respect to the window x coordinate, computed at the coarser granularity.

## Syntax

```ts
declare function dpdxCoarse(a0: f32): f32
declare function dpdxCoarse<V extends vec2 | vec3 | vec4>(a0: V): V
declare function dpdxCoarse<T extends Numeric>(a0: T): T
```

A signature may name a type the ambient file declares for its own use. These are those declarations.

**`Numeric`**

`type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u`

## Parameters

A parameter named by position (`a0`, `a1`) carries a name the ambient file generates. A call passes its arguments in order and names none of them.

- `a0` `f32``V``T`

## Return value

`f32``V``T`

## Description

Fragment stage only; `dFdx` on GLSL, which picks its own granularity; the CPU oracle returns zero.

The CPU oracle has no texture memory and no neighbouring fragments. The call throws unless the module was compiled with `{ gpuStubs: true }`, which returns a placeholder.

## Targets

**WGSL**

`dpdxCoarse(a)`

**GLSL ES 3.00**

`dFdx(a)`

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#derivatives)
