Skip to content

102-paint: paint roughness, metalness and glow on meshes - #591

Open
AlexZ005 wants to merge 10 commits into
mainfrom
feat/102-paint
Open

AlexZ005 wants to merge 10 commits into
mainfrom
feat/102-paint

Conversation

@AlexZ005

Copy link
Copy Markdown
Collaborator

Roadmap 102, lane 102-paint (brief plans/core/lanes/102/task-102-paint.md, scope correction applied). The UV editor's
existing Paint tool grows into painting on meshes. This is not a second painter: it uses the same tool, the same
brush stores and the same commit paths.

What it adds

  • Channels: roughness, metalness and glow (emission) beside colour. The first stroke makes the map (1k or 2k),
    starting from the material's own value. The slider lifts to 1 in the same undo step, so nothing changes until
    you paint. There is also a channel-alone view (local).
  • Viewport painting: drag on the selected object, with a ring on the surface. Strokes are object-space dabs
    rasterised through each triangle's own 3D-to-UV map, with seam padding. Alt+click picks; [ ] set the size;
    Esc cancels.
  • Brush: hardness, opacity, flow, eraser (back to the material's value), Mirror X (model strokes) and image
    stamps.
  • Shared materials: asks "this object only" or "all users". The unlink replicates through an additive
    objectParameters materialUnlink; the Inspector's Unlink uses the same helper, and was local only before.
  • Vertex-colour fallback: used when a mesh has no UVs or overlapping UVs (over 5 %), and the panel says why.
    On a low-poly face, a dab that reaches no vertex paints the nearest vertices facing it.
  • VR: Selected > Paint, the trigger paints, the stick sets size and flow, and a Paint ring holds the channel and
    brush options.
  • GLB export carries the new maps.
  • Wire: meshpaint / meshpaintend (ROOM_SCOPED, validated). The default round colour brush still sends
    uvpaint byte-unchanged. Commits ride map / mapSlot / meshgeo, one undo step per stroke.

Forks and their answers are in QUESTIONS-102-paint.md (orchestrator accepted Q1-Q6). Q7: the raster runs on the CPU,
not the GPU, so peers get byte-identical pixels.

Proof (Deck-local slots, on the final head)

  • uv-paint 25/0, uv-editor 45/0, mesh-paint (new) 41/0. The new suite covers: paint, live wire to a
    second peer, the same pixels by hash on both peers, undo/redo on both, a deterministic replay, mirror, eraser,
    the vertex fallback, reload, glTF export, and the memory gate (10 strokes at 2k keep at most one map's bytes in
    undo).
  • Unit meshPaintCore 24/24. svelte-check 274/37 (= baseline, ratchet OK), check:tokens clean,
    npm run build rc=0.
  • Not covered by e2e: the VR painter and its Paint ring (no XR runner on the Deck; the code follows the sculpt
    recipe).

New suites for the int's union battery: mesh-paint (e2e, listed in battery.json at 240 s, optional until a
runner measures it) and tests/unit/meshPaintCore.test.js (unit).

Save / sync compatibility (this lane touches both)

compat.cjs on Deck-local slots, with a v1.70.0 snapshot on 7079 and this branch on 7078:

  • An old scene loads unchanged: v1.70.0 made and saved a scene with a colour map, vertex colours and one material shared by two objects (10991 bytes).
    The lane opened it with no differences in the facts read (differs: none), and its re-save keeps the same
    top-level keys.
  • Feature unused = zero change: while that old scene is open, the paint engine chunk never loads (0 requests).
  • A lane-saved file opens in the newest release: the lane painted colour, roughness, metalness, glow and vertex
    colours, saved, and reopened all of it (29260 bytes). v1.70.0 then opened that file with the same pixels and
    values (differs: none).
  • Two peers + reload: mesh-paint (live wire to a second peer, same pixel hash on both, undo/redo on both, then
    a reload that restores the painted session with the same roughness hash).

Boot size (boot rule: up to ~3 KB of boot wiring, everything else lazy)

scripts/boot-size.cjs on two clean builds, v1.70.0 vs this branch, gzip -9 initial JS:

  • editor +2.4 KB (3459.0 -> 3461.4 KB, budget 3461.6: ok, with only 0.2 KB left for the int)
  • play +0.9 KB (2110.8 -> 2111.7 KB, budget 2113.0: ok)

What is in boot: the meshpaint validator and point quantiser (0.5 KB), the lazy-load glue in UvEditor (1.0 KB),
the Selected > Paint VR row, the materialUnlink applier, the commit helpers on materialMaps / uvEditor, and a
chunk split of the existing HudImagePicker (+0.3 KB net). Lazy: the painter (meshPaint, meshPaintCore), the brush
panel (MeshPaintPanel.svelte) with its prefs, the VR painter with its Paint ring and icons. A first build measured
editor +9.7 KB. 5 KB of that was the painter's ~400-name preload list written into UvEditor's boot chunk by its
import(); the painter is now imported from the lazy panel chunk instead.

Full battery owed: the int that merges it runs it, incl. uv-paint, uv-editor, mesh-paint. The lane skipped
its own battery on the orchestrator's instruction, because the PC queue is needed by 2.0-int, 61-int and 80a-int.

Docs fragment: ~/.code/lanes-30/after-102/102-102-paint/docs-fragment.md. Docs and changelog text are in
STATUS-102-paint.md under "For the orchestrator".

🤖 Generated with Claude Code

AlexZ005 and others added 10 commits November 21, 2026 09:39
…s, overlap, vertex dabs) + unit tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…engine + UV editor brush panel

- meshPaint.js (lazy): channels colour/roughness/metalness/emission, CPU tile raster
  (hardness/flow/opacity/eraser/mirror X/stamp), model strokes through each triangle's UV
  layout with seam padding, vertex-colour fallback via meshgeo colors, new map on first
  stroke (1k/2k) with the slider lift in the same undo step, shared-material ask,
  meshpaint/meshpaintend live wire (uvpaint unchanged for the default brush), colour pick,
  channel-alone view, viewport brush with a cursor ring
- meshPaintPrefs.js (leaf stores), meshPaintWire.js (validator leaf)
- materialMaps.commitPaintedMapSlot; uvEditor exports the colour surface + encoder
- objectParameters materialUnlink (paint 'this object only' + Inspector unlink now replicate)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vr/meshPaint.js on the sculpt recipe: pointer ray + brush ring, trigger = a desktop
stroke (one commit, one undo), stick sizes the brush / sets flow with ticks, hand label,
tracked hands ask for a controller. Radial: Selected > Paint, a Paint ring (channels,
Eraser, Mirror X, Done) the menu opens on during a session. Four lucide icons added
to the VR icon data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ttery row

Suite covers the panel controls, a roughness model stroke (new 1k map, lift, one undo),
live wire to B + same-pixels hash, undo/redo on both peers, a replayed stroke drawing
byte-identical pixels, Mirror X, eraser, vertex-colour fallback on a box (and its
refusal for map channels), reload, glTF export carrying the maps, and the 2k memory
gate. mapHash hashes what a channel reads, in one row order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uild trap)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ne 274/37)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… compares the right bytes

- vertexDab: a dab that reaches no vertex (a default box: 4 corners per face) paints the nearest vertices that
  face the stroke normal at full strength, so painting the middle of a box face is no longer a no-op. Mirrored
  dabs face the mirrored normal. Dense meshes keep the falloff path unchanged. Unit test added (24 green).
- mesh-paint e2e: the replay check hashes the sender's LIVE canvas before the commit (the commit is a lossy
  webp, the replay shows the raw canvas, so they could never match); the reload restore is done in the suite
  with a measured time instead of h.answerRestore's 10 s post-click wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…trokes keep in undo (0.29 MB of 16 MB)

usedJSHeapSize is quantised without precise memory info (it read 0.0 MB), so the gate now sums the strings in
the strokes' undo entries; the heap reading stays as an INFO line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t and the VR Paint ring go lazy

Boot gz vs v1.70.0 (scripts/boot-size.cjs on two clean builds): editor +9.7 KB -> +2.5 KB,
play +2.2 KB -> +0.9 KB. Both pages stay inside perf/boot-budget.json (editor 3461.5 of 3461.6 KB).

- MeshPaintPanel.svelte: the UV editor's new brush controls, imported with the painter when Paint
  is armed. meshPaintPrefs and the stamp picker leave the boot bundle.
- The painter is imported FROM the panel chunk: a dynamic import's preload list (meshPaint's whole
  static graph, ~400 chunk names) is written into the importing chunk, and in UvEditor's boot chunk
  that list alone cost ~5 KB gz.
- UvEditor reads the brush state through meshPaint's derived paintUi store.
- The VR Paint ring and its three icons register from vr/meshPaint.js on the first paint session;
  Selected > Paint uses the existing brush icon.
- mesh-paint suite waits for the lazy panel before checking its controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…int restore by DOM click, time reported

The lazy panel waited for the whole painter, so a cold dev server kept it off screen past the suite's 20 s wait.
It now shows as soon as its own chunk lands (the old brush paints until the painter follows). mesh-paint clicks
Restore through the DOM (a Playwright click gave up after 10 s on a busy page) and reports the restore time
(10-29 s under load) as INFO with the 60 s wait as the gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant