Yep—use screen-space derivatives.
Shader Graph doesn’t (always) ship a dedicated FWidth node, but you can build it exactly with:
fwidth(x) = abs(DDX(x)) + abs(DDY(x))
So: add DDX and DDY nodes, Abs both, then Add them. (Those derivative nodes are fragment-only, just like fwidth.) citeturn0search3
Make a tiny Sub Graph:
Inputs: Edge (float), X (float)
Nodes:
w = abs(DDX(X)) + abs(DDY(X))
- Output
AA = smoothstep(Edge - w, Edge + w, X)
This reproduces the classic aastep. Use it anywhere you’d normally do a hard step. (Same trick as the well-known AA alpha test / A2C approach.) citeturn0search26
If you have a distance d from the line center and want half-thickness t:
w = abs(DDX(d)) + abs(DDY(d))
alpha = 1 - smoothstep(t - w, t + w, d)
For a vertical UV line at u = u0:
d = abs(UV.x - u0)
- then compute
w from d as above and feed into smoothstep.
This is the standard way people fix aliasing on grid shaders / hard borders. citeturn0search6turn0search2
If you want the line to stay ~N pixels wide regardless of scale, work in screen space:
- Use Screen Position (or multiply normalized UV by screen width/height) to get pixel units,
- Build
d in pixel space, then the same aastep logic applies.
(DDX/DDY already give you screen-space gradients, which is why this works from any mapping.) citeturn0search23
- Custom Function node: you can paste a tiny HLSL helper if you prefer:
inline float AAStep(float edge, float x)
return smoothstep(edge - w, edge + w, x);
Then call it from a Custom Function node. citeturn1search9
- Alpha-to-Coverage (MSAA): for cutout lines, enabling A2C + the fwidth remap can further smooth edges on MSAA targets. citeturn0search26
- Sample subgraphs: Unity ships sample Shader Graph subgraphs for anti-aliased SDF edges—handy reference for how they do the derivative falloff. citeturn0search16
TL;DR: build fwidth with DDX+DDY, and replace hard steps with a smoothstep widened by that fwidth. That’s the go-to workaround for aliasing on lines in Shader Graph.