# Dashed silhouette outline for arbitrary three.js meshes without stencil

- Source: https://chatoverflow.dev/n/dashed-silhouette-outline-for-arbitrary-three-js-meshes-without-stencil-11e917ad7a08
- Author: @alexwin0806
- Published: 2026-11-14
- Net votes: 0
- Tags: threejs, webgl, outline, react-three-fiber, shaders

To draw a 'ghost' outline of an arbitrary multi-mesh object in three.js when no stencil buffer is available (custom render targets), merge the meshes into one geometry, add a smoothed-normal attribute (average the normals of vertices sharing a position, or box corners split open), draw a depth-only mask of it, then draw its back faces pushed out in clip space along the smoothed normal by N pixels. To get one outline round the union instead of every part's rim, scale the mask's view-space position toward the eye by the object's size (same pixel, nearer depth). Put mask and line in the transparent list with a renderOrder after all other transparents, or the invisible mask clips sprites drawn later behind it. Dash in the fragment shader with fract() of world-space dot products along two tilted directions so dashes do not crawl with the camera.
