---
name: code-built-character
description: Build, animate and render a 3D miniature inspired by the Witch Doctor from Warcraft Rumble. Use this skill to assemble the model in Blender, edit its procedural shapes or paint, tune its eight animation clips and spell effects, or inspect its three.js and Unity renders.
---
# Build the Witch Doctor
The character is defined in three Python modules. `kit/chars/wd_model.py` defines the skeleton, meshes and palette.
`kit/chars/witchdoctor.py` poses the rig and schedules each clip. `kit/chars/wd_fx.py` builds the spirit skull,
potion and healing totem. Follow the [illustrated walkthrough](references/11-witch-doctor-step-by-step.md) while editing them.
## Quick start
Use **Blender 4.4 or newer, including Blender 5.x** and **Node 18 or newer**. If the Blender executable is outside the standard macOS
locations, set `BLENDER` to its path. From a clone, enter the `kit/` directory next to this file. From a plugin
installation, copy that directory into your project first so your edits survive plugin updates.
```bash
npm ci
./build.sh
node tools/serve.mjs
```
Open the studio at `http://localhost:8100/`. Use **Turnaround** for front, side and back views, **Clay** to
inspect the geometry, and **Play clips** to test motion. The build prints the clip probes and round-trip errors,
then ends with `all checks passed`. To render stills in Unity 6 URP on macOS, run `./unity.sh` after building.
While editing animation, use `FAST=attack,hit ./build.sh` to probe those two clips. Use `QUICK=1 ./build.sh`
to preview a model change with 256 px textures and coarser probe sampling. Run the full build for final exports.
## Planning changes to the model
The supplied model builds directly from its source. When comparing a change against new artwork, collect the views that show the feature you are editing.
- **Front, side and back** views of the character, at the same scale and with the same lens. A turnaround sheet is
ideal. Front and back give widths, the side gives depths and the profile; without them the back and the depth are
guesses.
- **One colour image in light** (a 3/4 view or an in-game shot), for palette and value.
- **Close crops** of the face, hands and any prop that matters, and a **clay or neutral-light view** if one exists.
<!-- ‹guest · 2026-12-06› -->
If a view is missing, say so and choose: ask for it, use another image that shows it, or declare it invented and write
that down. The studio pages render the same views to compare (`front`, `side`, `back`, and a `turn` sheet), and Unity
writes `turnaround.png`. The [reference guide](references/01-study-a-reference.md) explains how to measure those views.
## The pipeline
| # | Stage | What it produces | Exit gate | Read |
|---|---|---|---|---|
| 1 | Study a reference | Written observations and measured proportions from front, side and back views, kept private | Every shape you will build has a measured size in px or `H` (character heights); missing views are named | `references/01-study-a-reference.md` |
| 2 | Model | Closed meshes from SDFs, one `Part` per mass | Every welded piece of 200+ triangles has positive signed volume; closed meshes have 0 open edges | `references/02-model-with-sdfs.md` |
| 3 | Rig and animate | Rigify rig, skin weights, springs, baked clips | Probes: no part crossings, floor within 5 mm, loops close, no quaternion flips | `references/03-rig-and-animation.md` |
| 4 | Paint | Albedo, AO, region, emissive textures from the surface itself | Crease 15–20 % darker in L* than the 2 cm mean, rim at most 8 % lighter | `references/04-paint-in-texel-space.md` |
| 5 | Verify | GLB, FBX, manifest, round trips | `node tools/verify.mjs` prints "all checks passed" | `references/05-verify-gates.md` |
| 6 | Render in three.js | Studio stills, clay view, record mode | Pixel samples agree with the paint targets, not only the eye | `references/06-render-in-threejs.md` |
| 7 | Render in Unity | URP studio scene, area-shadow shader, stills | Same checks as stage 6, plus no stale emissive maps | `references/07-render-in-unity.md` |
| 8 | Critic loop | Weighted rubric score per round | Target score reached, or two rounds in a row gain under 0.3: show the user and ask | `references/08-critic-loop.md` |
Stages 2 to 5 run in one command. The gates of stages 2, 3 and 5 fail the build. Stage 4's targets are measured
(`PAINTSTATS=1`) and judged by you; stages 1, 6, 7 and 8 are procedures with a recorded result. Stages 6 and 7 are
separate because they need a browser and the Unity editor. Stage 8 wraps the others and is what turns "I changed
things" into "the score went from 5.5 to 6.6".
## Operating rules
Each rule has a reason and a number from the Witch Doctor study. Follow them in order of appearance.
1. **Get the reference set first, then study it and measure it.** Front, side and back views, a colour image and
close crops (see above). Write what you see as ratios of the character's height `H`, widths from front and back,
depths from the side. A shape you only "feel" will drift by 20 % or more. Template:
`templates/observation-checklist.md`.
2. **Record where each measurement came from.** Keep the source view and the height used to normalize it in your observation notes.
3. **Few big masses first.** Silhouette and proportion carry 25 % of the score, part shapes another 25 %. Do not
paint or rig a body whose silhouette a critic has not accepted.
4. **Pick the voxel step `h` from the smallest feature you want to read.** On a 1.5 m character 4–9 mm worked;
triangles grow as 1/h² and memory with them (a 62k-triangle staff became 141k at h/1.5, 151 MB, and 251k at h/2, 352 MB).
5. **Soft shapes by surface nets, hard shapes by dual contouring, and never mix the two on one part.** Dual
contouring leaves a stair-step row along every diagonal of a block; use surface nets where a block must look
carved.
6. **Only leaf bones are scaled.** Scale on a bone with children shears everything below it as soon as the
children rotate. In `pose_frame`, the Witch Doctor scales `Torso` and `Skull`. It moves the
<!-- ‹guest · 2026-12-06› -->
jaw, brows, ears and crest with explicit offsets in `HEAD_KIDS`.
7. **A mirrored frame flips winding.** If `det(R) < 0` the faces of that part point inward. The signed-volume
gate exists because this happened: an entire staff head rendered see-through and the first diagnosis ("holes")
was wrong.
8. **Gate the animation, not just the geometry.** Probes cross-check collision groups, floor contact, loop seams and
transitions in the engine. A clip that looks fine in a viewer can still pass an arm through the torso.
9. **Paint from the surface, in texel space.** Per-triangle dihedral masks only fire on hard edges: on a smooth
skin they darkened creases by 1.8 %. A smooth curvature field darkened them by 16.8 %.
10. **Tone mapping: compare, do not assume.** Neutral beat AgX in the study: AgX washed out the saturated blue and
red. The studio page has a selector (Neutral, AgX, ACES) so the comparison is one click.
11. **Soft area shadows.** A 20-tap shadow average on the figure (24 mm disc on a 1.5 m figure) removed the hard
blotches that a single shadow tap produced; the floor uses 32 taps on a 9 cm disc.
12. **Measure the render, not the memory of it.** A critic's by-eye colour estimates were good to about ±15 %. When
the render's pixels were sampled, the critic withdrew two complaints (a "too yellow" shaft and a wrong foot ratio).
13. **Never trust a stale texture.** Emissive maps left over from an earlier model produced a red blotch and an orange
band only in Unity. Read maps from the manifest, never from a folder listing.
14. **One writer per file, one Blender at a time.** The study ran this way: parallel Blender builds on one machine
compete for memory and overwrite each other's `work/` folder.
15. **The critic is independent.** It sees the reference and your renders, not your intentions. Give it the
rubric (`templates/critic-brief.md`), ask it to quote the pixels it sampled, and score every row.
16. **Stop on a plateau.** Two consecutive rounds that gain less than 0.3 mean the method has hit its ceiling:
show the user the stills and ask, instead of looping.
## Honest limits
- A character built from code sits below a ZBrush sculpt. In the Witch Doctor study the critic score went
5.5 → 6.3 → 6.6 over three scored rounds against a target of 8.5. Round 5 was built and gated but never
re-rendered or scored. Do not promise "indistinguishable from the reference".
- Painted texture is the weakest row (4.0 → 5.0 → 5.8). Hand-painted brush variation and hue shifts inside a mass are
not something a procedural bake gives you for free.
- The kit has no automated visual evals, only numeric gates. The critic loop needs a person or an independent agent.
- Unity 6 needs a signed-in editor, and its first run imports the
project for several minutes.
## References
- `references/01-study-a-reference.md` — what to observe, what to measure, what you may and may not do with a reference
- `references/02-model-with-sdfs.md` — SDF primitives, surface nets vs dual contouring, tubes, resolution table
- `references/03-rig-and-animation.md` — Rigify metarig, pose math, IK, springs, the Clip API, probes
- `references/04-paint-in-texel-space.md` — AO, curvature field, tone triples, levels, measured targets
<!-- ‹guest · 2026-12-06› -->
- `references/05-verify-gates.md` — every gate in the build and in `verify.mjs`, with the failure each one caught
- `references/06-render-in-threejs.md` — studio lighting, materials, tone mapping, record mode
- `references/07-render-in-unity.md` — URP scene from nothing, shaders, supersampling, headless run
- `references/08-critic-loop.md` — rubric, critic brief, plateau rule, how to verify a critic's claims
- `references/09-case-study-witch-doctor.md` — the study this method came from: rounds, scores, incidents, limits
- `references/11-witch-doctor-step-by-step.md` — how the Witch Doctor was made, step by step, with the file and function of each step
- `references/10-pitfalls.md` — a flat list of mistakes with their cause and fix
- `templates/` — observation checklist, critic brief, `loop.json` state file
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.