Feature Library

Reskin seam for 2D games and visual apps

0.43 GPU · 0.69 CPU ms
A still of the Reskin seam for 2D games and visual apps demo
Still
The live demo starts when it’s in view.Drag the seam (or arrow keys on its handle) · pick a skin and a renderer for each side · click the water to drop a stone

A contract that lets one simulation wear any number of looks.

What it costs a frame

0.43 ms
0.69 ms
GPU
0.43 ms
CPU, median
0.69 ms
CPU, 95th pct
1.38 ms
Draw calls
0
Weight
Moderate

Measured 15 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.43–0.90, CPU 0.34–0.69 ms). What ran: Measured with Chart on the left and Lantern on the right, both on WebGPU and split half and half: about 300 to 500 instances a side in three layers, the field, the lights, glow and three bloom levels on the right, a stone dropped every 0.45 s so rings bend the field; both sides timed by their own timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool0.430.691.38
apple · Apple A19 Proin a browser tab · 16 November 20267.500.961.54
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20261.310.620.98

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. A 2D game whose art can be swapped (themes, seasons, an accessibility look, a retro mode) without touching its rules
  2. One simulation shown in several looks at once: a comparison, an editor preview, a split screen
  3. A dashboard, map or visual app that draws thousands of marks in one instanced call, with a Canvas 2D fallback that draws the same frame
  4. Night scenes in 2D: lamps, lanterns and beams that light what is near them, with glow and bloom
  5. Pixel art from sprites and code-drawn shapes alike, on a coarse grid that keeps every pixel the same size
  6. Rules that are tested, replayed and networked on their own, because nothing in them draws

Pitfalls, in brief

  1. The rules must not import anything that draws, and the walk must not change the state.
  2. Hand the same event list to every view, and drain it once: view.build() reads events, it never empties the rules’ list.
  3. setSkin() drops the effects in flight: they were made by the old skin’s handlers in its colours.
  4. Skins animate by the view’s own clock, which only moves in build().
  5. A palette given to extendSkin() replaces the base’s, and the borrowed draw functions read it: it must carry every slot they use.
11 more in brief
  1. A WebGPU canvas can never become a Canvas 2D one: getContext() returns null for the second kind.
  2. Instance sizes are half-sizes, and shapes point along +x before rotation, on both backends.
  3. The outline of a shape drawn with fill below 1 is 17% of its shorter half-size: right for marks and boats, far too thick on a big rectangle.
  4. With pixel set, the lit and glow layers are drawn on a grid of k device pixels per art pixel, k rounded to a whole number so every pixel is the same size.
  5. Canvas 2D cannot tint a sprite without per-pixel work: it draws sprites untinted.
  6. Canvas 2D leaves out the picture warp, and its bloom is three halvings of the glow canvas scaled back up, close to but softer than the WebGPU backend’s three-level filter.
  7. A WebGPU device can be lost (a driver reset, a sleeping laptop, another tab’s crash). render() then returns false for good: set onLost (or check lost) and move to createFlatBackend on a canvas of its own, and say so.
  8. A canvas wider or taller than the device’s maxTextureDimension2D cannot be drawn into. requestGpu() asks for the adapter’s own limit (often 16,384), and the backend draws a larger frame smaller and lets CSS stretch it.
  9. The light layer multiplies the lit layer only where lighting is on, and glows are added.
  10. render() returns false while the GPU is still busy with the last frame: keep the frame dirty and draw again next time, or a change is lost.
  11. The field and the lit layer share a rgba8unorm target: colours above 1 clip there.
16 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (JCGT, 2020): PCG, the integer hash behind every seeded number in TypeScript and the dither in WGSL.

Inigo Quilez, 2D distance functions: The standard box, regular polygon and triangle distances the shape shader uses, and the gradient-normalised ellipse estimate.

reskinskinsthemesseparation of rules and renderingviewdraw tableevent effectsinstancingsdf shapessprite atlaspixel art2d lightinglight layerglowbloomgrid warpshock ringscanvas 2d fallbackcanvas 2draw webgpuwgsldeterministicfixed timestepseeded

Near it in the frame