R3F Sketch Material: a hand-drawn ballpoint look for any mesh, all in the shader

Hey everyone! I made a material for React Three Fiber that makes any mesh look like it was drawn with a ballpoint pen. Scribbled hatching that follows the light, wobbly outlines that overshoot the corners, and hatched shadows on the ground. No textures for the strokes and no post-processing, it’s all in the shaders.

Live demo: https://r3f-sketch-material.vercel.app
Code (MIT): GitHub - abhishekmill/R3FSketchMaterial: Hand-drawn ballpoint sketch material for React Three Fiber · GitHub

How it works

  • Hatching: the surface is split into bands and the “pen” zig-zags inside each one. The zig-zag is two sets of slightly slanted lines meeting at the band edges, drawn as a distance field with fwidth() so strokes stay a constant pixel width. Some turnarounds get a small ellipse SDF loop, which is what makes it read as hand-drawn.
  • Shading: a tonal ladder. Sparse strokes in the light, denser in the mid-tones, and a second cross-hatch direction only in the dark areas.
  • No shower-door: the hatching is triplanar in object space (scaled to world size), so strokes stay glued to the model when the camera moves. Blend weights are pow(abs(n), 8) to keep the transition zones tight.
  • Outlines: an inverted hull pushed out in clip space for the silhouette, plus EdgesGeometry turned into seeded, wobbly strokes that overshoot the corners.
  • Shadows: a patched ShadowMaterial (onBeforeCompile) that draws scribbles wherever the shadow map says “shadow”.
  • Wash out / reveal: one shared uniform object plugged into every material. Noise plus a height sweep decides where the ink fades first, with a darker “wet edge”. Switching between ballpoint, marker, pencil and thin pen washes the scene out and redraws it with the new pen.

Everything is tweakable in a leva panel. Happy to answer questions, and I’d love to hear what you’d use it for!

Car model by Quaternius (CC-BY) via Poly Pizza.

1 Like