Intrinsics1 min read
fwidth_coarse
Computes coarse screen-space filter width.
Reading Time
1 min
Word Count
112
Sections
7
Try It Live
Test fwidth_coarse in a live shader
Open the playground, start from a visual preset, and wire fwidth_coarse into the fragment stage to see how it behaves with real values.
Open PlaygroundThe fwidth_coarse function returns a coarse estimate of abs(ddx_coarse(x)) + abs(ddy_coarse(x)). Coarse derivatives may reuse derivative results across larger pixel groups, which can be useful when consistent filtering is more important than the finest local estimate.
Live Demo
Signature
bwsl
fwidth_coarse :: (T x) -> T
Where T can be float, float2, float3, or float4.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | T | The value to compute coarse filter width for |
Return Value
Returns abs(ddx_coarse(x)) + abs(ddy_coarse(x)).
Example
bwsl
float stripe = sin(uv.x * frequency);
float width = fwidth_coarse(stripe);
float mask = smoothstep(threshold - width, threshold + width, stripe);Compiled Output
When compiled to SPIR-V:
spirv
OpFwidthCoarse
When compiled to GLSL ES:
glsl
fwidth(x)
When compiled to HLSL:
hlsl
fwidth(x)
See Also
- fwidth - Standard filter width
- fwidth_fine - Fine filter width
- ddx_coarse - Coarse x derivative
- ddy_coarse - Coarse y derivative