Skip to content

Instantly share code, notes, and snippets.

@sugi-cho
Last active August 14, 2018 07:36
Show Gist options
  • Save sugi-cho/b2322638c86f251a8279dfa6345f2c1f to your computer and use it in GitHub Desktop.
Save sugi-cho/b2322638c86f251a8279dfa6345f2c1f to your computer and use it in GitHub Desktop.
Quad-Wireframe using UV
half wire(half2 uv) {
half2 d = fwidth(uv);
half2 a2 = smoothstep(half2(0, 0), d*1.0, uv);
half w = 1.0 - min(a2.x, a2.y);
return w;
}
fixed4 frag(v2f i) : SV_Target
{
float2 uv = frac(i.uv * 20);
half w = max(wire(uv), wire(1 - uv));
return w;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment