fwidthFine
On this page

fwidthFine

Function

The screen-space width is the sum of absolute horizontal and vertical derivatives. It estimates how much a value varies across a pixel.

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: fwidth

Targets

Compare examples

Compare a flat field, a horizontal ramp, and a diagonal ramp. Both directions contribute positively.

Model assumptionsf(px, py) = a × px + b × py + c

Example 1a = 0; b = 0; c = 5
5555
Field values at neighbouring pixels. The lower row adds a vertical pixel step.
Result
0
Example 2a = 0.25; b = 0; c = 0
00.2500.25
Field values at neighbouring pixels. The lower row adds a vertical pixel step.
Result
0.25
Example 3a = 0.25; b = -0.5; c = 1
11.250.50.75
Field values at neighbouring pixels. The lower row adds a vertical pixel step.
Result
0.75

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 soften a procedural edge by approximately one pixel.

Inputs and limits

The example uses affine fields. It is a pixel footprint estimate, not a gradient length or a CPU derivative. This operation belongs in fragment-stage uniform control flow.

For shader input rules and precision, consult WGSL and GLSL ES 3.00.

WGSL
fwidthFine(a)
GLSL ES 3.00
fwidth(a)

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

abs(dpdxFine(x)) + abs(dpdyFine(x)).

Syntax

declare function fwidthFine(a0: f32): f32
declare function fwidthFine<V extends vec2 | vec3 | vec4>(a0: V): V
declare function fwidthFine<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.

Return value

f32VT

Description

Fragment stage only; fwidth on GLSL; the CPU oracle returns zero.

Targets

WGSL
fwidthFine(a)
GLSL ES 3.00
fwidth(a)

See also

Edit this page Report a problem