Shuangren 霜刃 ("Frost Blade") is a wuxia soulslike that runs only in the browser. It is set during the An Lushan Rebellion (755 to 757). The protagonist, Shen Jibai 沈既白, is a blade grinder branded with "reversed meridians" (逆脉). He fights his way from Mount Zhongnan 终南山 to the Bianqiao bridge over the Wei River 渭水, and the story ends in front of Hanyuan Hall in the Daming Palace in Chang'an 长安. Three chapters, three bosses. Nobody dies, they are only "defeated". There is no blood, only ink, frost, and sparks.
About six days passed between the first session and today. The code is 280 TypeScript files, 89,057 lines, with a single runtime dependency: three.js 0.187. Almost all of it was written by AI coding agents: 9 main sessions, transcripts from 366 subagents, and 31 orchestration scripts. My role was closer to art director, producer, and playtester.
This post covers four things: how the art direction was set and then overturned, how I got the game to run in a single browser tab, a few graphics tricks I like, and how a group of agents wrote the same game in parallel without stepping on each other.
First, a day-by-day log. Every section below comes back to one of these days.
Wednesday, November 11, 2026. I opened the first agent session a little after 1 p.m. All I gave it was a one-line premise: the An Lushan Rebellion, a blade grinder, a soulslike you can play in the browser. Within three hours the interface contracts, architecture doc, game design doc, and a 681-line art spec were written. By the end of the day, 97 source files existed.
November 13–14, 2026. The characters got bodies: models generated with Tripo, motion capture data, packs of enemies, wall-hugging and ledge-climbing moves. The repo got its first git commit at 1 a.m. on the 14th. Everything from the two days before lived in the agents' working directories, which is why the git history can't be used as a timeline.
November 15, 2026. A full day of scene audits. Round after round of screenshots, picking out flaws, reworking PBR materials, reworking the sky, adding procedural detail. My verdict on the first few rounds was "mediocre, the changes barely show" (很一般,看起来都不明显). So I set a rule: every change has to be obvious at a glance from the follow camera.
November 16, 2026. Cleanup and performance. I had a style lab built that renders several art styles side by side, and picked the realistic one. The last change landed at 10:46 p.m.
1. Art: I wrote a beautiful spec, then threw it out
Version one: ink wash
The art spec was done on the first afternoon, 681 lines. Its core in one sentence: "The whetstone is the inkstone, the sword is the brush, frost is white. Others paint with ink; Shen Jibai breaks the ink with white."
The reference was the "Ink-Dyed Jianghu" (墨染江湖) skin series from Honor of Kings. The spec distilled twelve transferable principles from it, such as "ink belongs to the world, the hero is white": he is the patch of blank paper that moves through the frame. The whole image was allowed only three accent colors:
Each chapter's fog was "the color of the paper": misty teal #A9C2C0 for Mount Zhongnan, night rain #0F1A24 for the Wei River, and for Chang'an a burn from charred black #1A1210 to the pale white before sunrise, then to the gold of dawn.
Version two: no outlines
After the first playtest, my feedback was one line: "black outlines everywhere, it looks dirty" (全是黑描线,很脏).
Depth-edge ink lines, fold lines, pooled ink, and character outlines were all set to 0 at every quality level. The core of the spec no longer existed in the game.
Version three: the style lab
Finally I had an agent build a switchable style lab, where the same scene can flip between five styles with one click:
real: cleaned-up PBR realism, the current defaultoff: an earlier, foggier gradepainted: palette-pulled albedo, a two-step light/dark painterly ramp, and a banded Kuwahara filterguofeng: rich Chinese mineral pigments (azurite, malachite, ochre, cinnabar) plus a paper texturepixel: about 300 pixels tall, 8 color levels, ordered dithering
- mist
- ×0.5
- contrast
- ×1.3
- saturation
- ×1.1
- brush
- off
- paper
- 0
A drawn stand-in, not a game frame: each look applies its preset values from the game's style.ts. Grayscale, so saturation and the guofeng mineral palette don't show.
I went with realism. Not because ink wash looked bad, but because in a game where you watch enemy windups and time your parries, clarity matters more than style.
The sun doesn't get to wander
One more piece of feedback changed the whole lighting system: "as I run, I can see the sun moving like crazy" (跑着跑着就能看到太阳疯狂的移动).
The original design moved the sun continuously along the level route, from afternoon to sunset to night. It sounds cinematic. In play, you ran twenty meters and the shadows swung to a new angle.
It became a stepped time of day: three fixed stages, afternoon, dusk, and night. Afternoon and dusk share the same sun direction. Stage changes happen only at moments you can't see: loading an area, resting at a lantern, the camera jumping more than 8 meters in one frame, a boss intro cutscene. Otherwise it cross-fades linearly over about 6 seconds. After the change, the key light elevation is 38° in every frame up to the boss cutscene (before, it went 15° → 32° → 6°).
Drag along the path. Afternoon and dusk share one sun direction; a stage changes at a hidden moment or over a ~6 s crossfade.
2. Terrain, sky, weather: whatever can be code, is code
The game ended up using plenty of outside assets (AI-generated models, motion capture, scanned textures from Poly Haven), but the terrain, sky, weather, water, vegetation placement, and most of the architecture are generated in code.
Terrain
The terrain is a 513×513 heightmap covering 512 meters on a side. It is built in order: noise layers, then "stamps" applied in sequence (hills, flattening, rectangles, paths), then optional hydraulic erosion, then derived maps. The noise is fBm with domain warping: two low-frequency noise fields first "twist" the sample point, and then the noise is sampled.
let sx = x, sz = z;
if (L.warp) {
const wf = f * 0.5;
sx += (fbm2(x*wf + 19.1, z*wf + 7.3, 2, spec.seed + l + 1000) - 0.5) * 2 * L.warp;
sz += (fbm2(x*wf - 11.7, z*wf + 23.9, 2, spec.seed + l + 2000) - 0.5) * 2 * L.warp;
}
v += L.amplitude * (fbm2(sx*f, sz*f, L.octaves, spec.seed + l, 2, 0.5, L.ridged === true) - 0.5) * 2;Mount Zhongnan uses seed 7103 and two noise layers: a low-frequency layer for the large relief (26 m amplitude, warp 30) and a ridged detail layer. The physics heightfield and the LOD 0 mesh share the same triangulation, so "the character's feet never disagree with the picture."
512 m square at 257² (the game uses 513²). Noise layers only; the game then adds its stamps (hills, flattened yards, paths). Zhongnan is seed 7103; Weishui 9203, Chang'an 3301.
Erosion is a story of "built it, tested it, turned it off." The particle-based hydraulic erosion works: droplets pick up sediment where they speed up and drop it where they slow down. I tried 140,000 to 280,000 droplets. Loading took 0.7 seconds longer, and at gameplay distance the carved gullies were completely hidden by grass and trees. So it is off for Mount Zhongnan.
Sky
The sky is Nishita single scattering: Rayleigh (why the sky is blue) plus Mie (haze and the glow around the sun), with 16 steps per view ray and 6 steps toward the sun at each one, baked into a 128×64 half-float lookup table. The table is re-rendered only when the sun moves, and each render takes under 0.1 ms.
const vec3 kR = vec3(5.5e-6, 13.0e-6, 22.4e-6); // Rayleigh
float kM = 21e-6 * haze; // Mie
const float hR = 8e3, hM = 1.2e3, g = 0.76;
for (int i = 0; i < N; i++) {
vec3 x = r0 + r * (t + ds * 0.5);
float h = length(x) - rP;
float dR = exp(-h / hR) * ds, dM = exp(-h / hM) * ds; odR += dR; odM += dM;
/* inner loop: accumulate lR, lM toward the sun */
vec3 att = exp(-(kM * (odM + lM) + kR * (odR + lR)));
tR += dR * att; tM += dM * att;
}The clouds are a single curved layer 1.6 km above a planet of radius 6,360 km, so they stretch all the way to the horizon. Measured, the procedural sky costs about the same as the old 2k HDRI panorama (4.6 / 7.0 ms vs 8.7 / 8.8 ms), but it can follow the lighting.
Weather and wind
Weather is a GPU-instanced particle volume wrapped around the camera: peach petals and bamboo leaves on Mount Zhongnan, rain streaks at two depths plus ripples on the water at the Wei River, sinking ash and rising sparks in Chang'an. The key point: each particle's position is a pure function of its seed and the accumulated drift, so there is no per-particle simulation and nothing ever "pops."
Wind is a shared gust field: four gusts cross the map on a 24-second cycle, layered over a broader breeze. Vegetation sway, the sheen on the grass, and the flight of petals and leaves all read this field, so leaves only fly where a gust is passing.
3. Running in one browser tab
The target was 60 fps at 1080p on medium settings, on machines like an M-series integrated GPU or a GTX 1650.
Adaptive resolution
This is the part of the renderer I think pays off the most. It uses WebGL2's EXT_disjoint_timer_query_webgl2 to measure the real GPU time of each frame, then moves between four internal resolutions: 100%, 88%, 78%, and 70%.
if (timer.available) {
if (timer.fresh) a.gpu += (timer.ms - a.gpu) * 0.12; // EMA of GPU ms
hot = a.gpu > GPU_HOT_MS; // 14.5 ms
const up = a.idx > 0 ? SCALES[a.idx - 1] / SCALES[a.idx] : 1;
cool = a.idx > 0 && a.gpu * up * up < GPU_COOL_MS; // would one step up still fit under 10.5 ms?
}
a.hot = hot ? a.hot + realDt : Math.max(0, a.hot - realDt * 2);
if (a.hot > 1.2 && a.idx < SCALES.length - 1) { a.idx++; a.settle = 1.5; applySize(); }
else if (a.cool > 5) { a.idx--; a.settle = 1.5; applySize(); }A few details:
- Stepping down: smoothed GPU time stays above 14.5 ms for 1.2 seconds.
- Stepping up: it ignores the current time and looks at the predicted time instead. Pixel count scales with the square of the resolution, so the prediction is . It steps up only after the prediction stays under 10.5 ms for 5 seconds.
- The 4 ms gap between the two thresholds prevents oscillation, and every switch is followed by a 1.5-second cooldown.
- Safari and Firefox don't expose timer queries by default, so there it falls back to frame intervals: anything over 1/52 s counts as "hot." If stepping down one level doesn't improve frame time by more than 7%, the bottleneck is the CPU or the display refresh rate, not pixels, so it steps back up and locks.
Illustrative load, not a measurement. The stepping rules and thresholds are the game's. At 88% the middle stretch would cost about 9.3 ms, but stepping back to 100% predicts 12 ms, so it stays.
One cleanup pass: Chang'an street from 16.3 ms to 2.8 ms
The biggest performance win came from a single "cleanup plus performance" pass. The main changes: god rays went from 20 steps to 12, SSAO moved to half resolution with 4 samples, the far shadow cascades went from updating every 3 frames to every 10, and MSAA was turned on for the HDR target.
To be honest about these numbers: they were measured in headless Chrome on Apple silicon while other agents were rendering on the same GPU. The Chang'an "before" figures also include detail and POM costs that another agent was cutting at the same time.
A few debugging stories
500 draw calls. One scene shot past 500 draw calls and 6.2 million triangles. The first suspect was props another agent had added. The real cause was ground vegetation: in 64-meter cells, grass blades that the vertex shader had already shrunk to zero beyond 34 meters were still costing 120 to 150 draw calls. The fix hides any whole cell that is more than 4 meters past the fade distance, every frame.
Merged geometry broke culling. To cut draw calls, the houses inside Chang'an's ward walls were merged into the street sectors. That broke frustum culling for whole sectors, adding 100 draw calls even when facing away from the street. The final fix gave the wards and the palace their own sectors, at an extra cost of only 4.5 draw calls and 15,000 triangles.
Two to three times over the triangle budget. The budget said 1.5 million. Mount Zhongnan measured 3.19 million on average. But GPU time was only 6.75 ms, because most of those triangles were instanced vegetation. A budget is a hint; the profiler is the truth.
Asset compression
4096 PNG → 2048 WebP, quantized attributes
characters, props, weapons (after includes LOD and crowd variants)
FBX → 22 bones, 30 fps, int16
Each bar is scaled to its own before size.
4. Graphics tricks I like
Fog in post, sword trails after the fog
Rendering happens in two passes. The first pass is everything that writes depth: lighting, shadows, 4× MSAA, then fog applied in post-processing. The second pass is the transparent things that don't write depth: particles, sword trails, weather, glow cards. They are drawn after the fog. That way the fog can never wash out a sword stroke, a petal, or a spark.
Analytic height fog
The fog is not ray-marched. It is the closed-form integral of exponential height fog along the view ray:
and are the heights of the two ends of the ray relative to the fog base, is the height falloff, and is the distance. Two layers of scrolling noise modulate the density, which gives fog banks that drift through the near and middle distance. The fog color also depends on view direction: warmer looking toward the sun, cooler and one step darker looking away.
Sword trails dry out instead of fading
The trail's fragment shader has about 60 "bristles": noise that is high frequency across the stroke and low frequency along it. Over time a threshold rises, and instead of turning transparent the stroke dries out until only a few strands remain. The gaps are "flying white" (飞白), the dry-brush effect in calligraphy.
// About sixty bristles across the stroke, changing slowly along it. The gaps are flying white.
float n = fbm3(vec2(v*60.0 + vSeed*31.0, u*2.0 + vSeed*7.0))*0.75
+ vnoise(vec2(v*21.0 + vSeed*5.0, u*8.0))*0.25;
float streak = clamp((n - 0.22) / 0.56, 0.0, 1.0);
// Drier toward the tail and with age; the stroke dries into strands instead of fading out.
float th = mix(vS.x, vS.y, u) + (1.0 - life) * 1.15 + vBrk * 1.2;This is one of the few things from the ink-wash spec that survived.
Lantern reflections on water
The water surface is a single draw call with no render targets. Eight warm lanterns each cast a long reflection across the water: compute the lantern's mirror point across the water plane, then draw an anisotropic Gaussian along the view direction, smeared sideways by the wave slope.
The dot grid on the hero's robe
For a while, a regular grid of dots appeared on the hero's white robe at the edge of his own shadow. The agent ruled out suspects one by one with A/B tests: the albedo map, the normal map, receiveShadow, SSAO, normalBias. None of them. It only disappeared when the shadow radius was set to 0. The cause: three r187's PCF rotates its 5 samples per pixel using interleaved gradient noise, which happened to form a regular pattern at shadow edges. The fix patches the shader chunk at module load to pin the rotation angle to .
5. Getting a group of agents to write one game
This is the part I find most interesting.
Contracts first, then parallelism
About three hours after the first session started, the contracts, architecture doc, GDD, and art spec were all written. Then ten modules started in parallel: core, engine, world/env, world/level, character, combat, ai, fx+audio, ui, game.
The rules are in the first section of ARCHITECTURE.md. The core ones:
- Ownership is by path. Each agent may only edit its own paths.
src/core/**belongs to the lead and is "final." Even if a contract is wrong, it can't be changed: "work around it in your own module and report it in your handoff notes." - Modules may not import each other. They can only import
threeandsrc/core/*. Cross-module access goes through the typedGamecontext (contracts.ts, 2,013 lines) or the event bus. - No new npm dependencies, no network access.
- Each module has one public
index.ts, and the first version is an empty shell that satisfies the contract. Factories run in two steps (createX(game)first, theninit()), so startup order is always safe. - The project must pass
npm run typecheckandnpm run buildat all times. That is the merge gate.
The design phase was itself an orchestration: three independent story pitches written in parallel, then the combat spec, then a reviewer that scored and merged them, then an architect that scaffolded the project, wrote the contracts, and listed a work plan of at most 9 modules, and finally a read-only adversarial review. The architect's prompt ended with: "npm run typecheck and npm run build must both pass on the empty shells. Fix until they pass."
- owns
- src/engine/**
- imports
- three src/core/*never another module
- entry
- createRenderer · createCameraRig · createInput
Merge gate: npm run typecheck and npm run build pass at all times.
window.__game: a remote control for agents
Agents can't play the game the way a person does, so the game exposes an automation API for them:
snapshot(): frame number, state, area, fps, draw calls, triangles, player, enemies, bossteleport(),loadArea(),quickStart(): jump to any landmarkspawnBoss(),spawnEnemy(),killAll(),god()press(action, frames),move(x, y): inject inputstepFrames(n): run n simulation steps synchronouslyaudit(): find floating, sunken, and intersecting objects
This API works because the simulation is deterministic: fixed 60 Hz, no Math.random or Date.now. The same inputs plus the same number of steps give the same snapshot. Every area must have named landmarks, so an agent can teleport anywhere to verify its work.
There is a line in ARCHITECTURE.md I like a lot: "Every module's task description ends with acceptance checks; 'it compiles' is not one of them."
The screenshot audit loop
Visual quality moved forward through a screenshot audit loop. Each round:
- Fixed camera spots, for example 12 points across three areas, in a 1280×720 follow camera.
- The agent captures "before" shots, changes the code, then captures "after" shots, along with fps, draw call, and triangle stats.
- A ranked list of "what hurts the image most." The first round had 10 items, such as "faceted low-poly rocks" and "the waterfall is a flat white card."
- A change table: file, function, what changed.
- A one-line performance comparison, plus "still unresolved."
The audit doc is 795 lines and covers more than twenty rounds: vegetation, lighting, distant views, building facades, PBR, sky, decoration, cleanup, and more. One "clipping sweep" teleported every 15 meters along each area's path and took a screenshot facing each of four directions, 184 frames in total, all reviewed on contact sheets.


Human feedback was part of the loop too. Each of my exact remarks became a tightly scoped task with its own backup directory: "mediocre, the changes barely show," "the lighting is overdone" (光影太夸张), "black outlines everywhere, it looks dirty," "as I run, I can see the sun moving like crazy."
What parallelism costs
- The GPU is shared, so performance numbers lie. Once I measured 21 to 23 fps under a tower in Chang'an, and it wouldn't reproduce on an idle GPU. Another agent's browser was competing for the GPU.
- Before/after comparisons get contaminated by parallel work. "The Chang'an 'before' also includes detail and POM costs that the kit agent was cutting at the same time."
- Parallel edits interrupt each other. One agent's file change triggers Vite hot reload, which kills a long test another agent is running.
- Silent framework bugs. Instanced materials were cloned with
MeshStandardMaterial.copy(), andcopy()resetsdefines. About 90 instanced prototypes quietly lost their shader hooks. - Git doesn't capture any of this. The main branch has only 14 commits, and the first one contains 1,038 files. Most of the work happened in an uncommitted working tree and 59 backup directories named after tasks. This is the thing I will definitely change next time.
6. What I learned
- Contracts first is what makes parallelism possible. Ten agents could work at once because they couldn't see each other, only the contracts.
- Giving an agent an interface to drive the game is far more useful than giving it a manual. A deterministic simulation plus
stepFramesturned verification into something an agent can do by itself. - Screenshots are the most honest test. Compiling and type-checking say nothing about whether the image looks good.
- Art direction has to survive a playtest. However well a spec is written, one player saying "it looks dirty" can overturn it.
- A budget is a hint; the profiler is the truth.