Detect unintended graphical changes by comparing screenshots before and after a change. A pixel-difference tool with noise tolerance, masks for areas that always change, and a side-by-side before / after / diff sheet that highlights what moved. Covers making screenshots repeatable (seeds, pausing animation, fixed sizes), WebGL screenshots from the viewer's browser, and reviewing diffs. Use afte...
Download skill (.zip) Files on GitHubGame visual regression
python3 <skill>/scripts/visual-diff.py before/ after/ # folders: pairs files by name
python3 <skill>/scripts/visual-diff.py before.png after.png --mask 0,0,320,60 --threshold 0.5
For each pair it prints the % of changed pixels and the changed area, and saves <name>-diff.png:
before | after | changes in magenta (yellow box = changed area, blue = masked). Exit code 1 if anything changed over the
threshold (default 0.5%). Always view the diff sheets: the number says how much, the picture says what.
Getting comparable screenshots
- Same viewport size, same state, same moment. Use playwright-game-testing steps (
{"shot": "title"}) with--out before/, make the change, run again with--out after/. - Remove randomness: seed (
?seed=1). Freeze time if possible (__game.paused = true, or a?freezedebug flag that stops animation after N frames). - Mask things that always move: score, timer, particles, blinking prompts (
--mask x,y,w,h, CSS pixels; repeatable). --tolerance 24(per channel, 0–255) ignores antialiasing and compression noise. Raise it for gradients and video, lower it for pixel art.
WebGL games
The sandbox can’t render them. Take screenshots in the viewer’s browser: look_at_preview before and after (save them),
or check_gpu_render with the same actions. Compare with the tool. Expect small GPU differences between machines, so compare
shots from the same browser, with a higher tolerance (~40).
Reading results
| Diff looks like | Likely cause |
|---|---|
| Whole screen changed slightly | Scaling or DPR change, color space, font loading, antialias setting |
| Everything shifted | Layout, letterbox or camera offset changed |
| One element changed | That sprite, UI element or shader. Check it’s intended |
| Text area changed | Font didn’t load in time (await document.fonts.load), or copy changed |
| Random speckles | Particles or randomness: mask or seed them |
Intended change: keep the new shots as the next baseline (game-regression-testing does this with record).