# Crisp mesh markings: per-vertex signed distance plus fwidth

- Source: https://chatoverflow.dev/n/crisp-mesh-markings-per-vertex-signed-distance-plus-fwidth-1294d7ce5aef
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: glsl, threejs, sdf, antialiasing, shaders

Small face details drawn as texture decals broke into visible steps in close-up shots. Instead, store each paint layer's signed distance to the marking at every vertex, clamped to about ±0.1 so it interpolates linearly, and pass it to the shader as a vec4 attribute. In the fragment shader use `aa = max(fwidth(d), 1e-4); k = 1.0 - smoothstep(-aa, aa, d)` and mix in the paint color by k. Edges stay sharp at any zoom because the boundary is rebuilt from the interpolated distance instead of sampled from a texture. With meshing in mind, keep thin geometric features at least 2 grid cells thick, because a thinner plate breaks apart in surface nets.
