The live demo starts when it’s in view.Drag to turn round the block · switch the edge filter and the shadow box to compare · lower the sun
One sun’s shadow that stays crisp and still.
One sun’s shadow that stays crisp and still: the shadow map is refitted every frame to the ground the camera sees (at three heights, for relief and tall buildings, up to a distance you set), its size in fixed steps and its centre snapped to whole texels in the light’s plane, so an edge fixed in the world never shimmers as the camera moves; edges are filtered by a fixed 3×3 tent in texel space (three r185’s PCFSoft, which r186 removed from the WebGPU renderer, where asking for it falls back to three’s PCF and its taps rotated by screen noise: dithered edges that crawl as the view pans). The depth bias holds about 4 cm whatever the box’s depth, the normal bias grows as the sun drops (no acne stripes at dawn), and a receiver fix measures it along the geometric normal (no dark strip moving along wall bases under normal maps). From a game that tuned it at length; a fixed box over a whole scene spends the map on empty country and turns edges to stairs.
What it costs a frame
GPU
0.22 ms
CPU
0.33 ms
02468101216.7 ms
GPU
0.22 ms
CPU, median
0.33 ms
CPU, 95th pct
0.82 ms
Draw calls
12
Weight
Light
Measured 18 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 0.22–0.24, CPU 0.29–0.36 ms). What ran: A block of 76 small houses with overhanging roofs and fences, three towers, one 2,048-px sun shadow fitted to the view each frame and filtered by the tent, the camera turning slowly round the block. Phones: tiers are being measured next.
How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
Typical frame ?
3.66 ms
1% low ?
148 fps
Varies by ?
±1.15 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · referenceHow long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.
Frames run back to back, each starting once the GPU has finished the last, so frame times show the work itself. They have a floor of about 4–5 ms from the browser’s own scheduling: GPU and CPU ms stay the measure of cost.
Frames
Median (p50) ?
3.66 ms
p95 ?
5.58 ms
p99 ?
6.47 ms
Slowest ?
7.33 ms
Mean ?
3.69 ms
Standard deviation ?
1.15 ms
1% low ?
148 fps
0.1% low ?
137 fps
Hitches ?
0 of 600
Over budget ?
0 of 600
Main thread
Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 1.4 / 1.4 ms
Input
No input during this run.
Memory
JavaScript heap ?
35.0 → 37.3 MB
Growth ?
+2.29 MB
Browser
JavaScript a frame ?
0.01 ms
All tasks a frame ?
0.60 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
16%
Garbage collection
Collections ?
7 (7 minor, 0 major)
Pauses ?
2.3 ms in all, longest 0.6
What it needs
Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages
With an agent
install("sun-shadow")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up
What it’s for
Any outdoor scene with a sun: towns, terrain, games, product shots outside
Shadow edges that look dithered or crawl when the camera pans (three r186 and later on WebGPU)
Staircase shadow edges under eaves and fences in a large scene
Acne stripes at a low sun, and a dark strip along wall bases with normal maps
Pitfalls, in brief
Call fit(camera) every frame before rendering, after the camera moved.
PCFSoftShadowMap does nothing on three r186+ with WebGPU: it falls back to PCFShadowMap with a warning, whose taps turn with screen noise.
The further the box reaches (distance), the coarser each texel: about 4 cm at 80 m across a 2,048 map, 20 cm at 400 m.
The box covers the ground at three heights (24 m below to 48 m above the level given to fit) plus 64 m behind: taller casters out of view need a larger reach.
Three picks a light’s shadow filter once, when it first draws the shadow, and never looks again: setting filterNode (or the soft option) later does nothing.
2 more in brief
The receiver fix is a node: it works on node materials (receivedShadowPositionNode).
One cascade: very large views (a flight over 5 km) want cascaded shadows instead.
7 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From HaTac. Adapted from published work, named below.
three.js (MIT): the tent filter is r185’s PCFSoftShadowFilter, ported to TSL with four gather-compares
Make the shape of bright ground readable: lengthen its normal’s tilt for lighting, distinguish lee and windward faces, and bake local horizon occlusion into hollows.