Intrinsics1 min read

fwidth_fine

Computes fine-grained screen-space filter width.

Reading Time
1 min
Word Count
107
Sections
7
Try It Live

Test fwidth_fine in a live shader

Open the playground, start from a visual preset, and wire fwidth_fine into the fragment stage to see how it behaves with real values.

Open Playground

The fwidth_fine function returns a fine-grained estimate of abs(ddx_fine(x)) + abs(ddy_fine(x)). It is useful when you want anti-aliasing widths based on per-pixel derivatives rather than coarser derivative groups.

Live Demo

Signature

bwsl
fwidth_fine :: (T x) -> T

Where T can be float, float2, float3, or float4.

Parameters

ParameterTypeDescription
xTThe value to compute fine filter width for

Return Value

Returns abs(ddx_fine(x)) + abs(ddy_fine(x)).

Example

bwsl
float sdf = signedDistance(position);
float width = fwidth_fine(sdf) * 0.5;
float alpha = 1.0 - smoothstep(-width, width, sdf);

Compiled Output

When compiled to SPIR-V:

spirv
OpFwidthFine

When compiled to GLSL ES:

glsl
fwidth(x)

When compiled to HLSL:

hlsl
fwidth(x)

See Also