Skip to content

A posed skinned model is added and removed in place - #183

Merged
yujiaxu-ops merged 21 commits into
mainfrom
skinned-add-remove
Nov 21, 2026
Merged

yujiaxu-ops merged 21 commits into
mainfrom
skinned-add-remove

Conversation

@yujiaxu-ops

@yujiaxu-ops yujiaxu-ops commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

A character that comes or goes while the game runs rebuilt the scene. Now a posed skinned model of a model the scene has is added in place, and any is removed in place.

  • Added. A mesh of its own in the room for edits, as the build makes one: its triangles skinned on the CPU once for the pose it comes in, a job of the skinning pass for its next poses, skinned from the model's one copy of its corners. The pass's table and the buffers grow with it.
  • Removed. Its instance is out, the build's or an edit's. One an edit placed gives back its triangles, its record and rows, its previous vertices and its job's slot, and the next one placed takes them.
  • A deforming mesh's previous frame's vertices are where its instance says. The kernel found them by the triangle's place among the dynamic triangles, which a mesh in the room does not have. The first hit's motion reads through the instance's record, under a feature of its own (F_DEFORM: a scene with a mesh that deforms); no loop is added. In every kernel the read cost a scene without such a mesh 0.6 % of its GPU frame (a flight over a city, five alternated pairs of five).

A fault found on the way: what a batch changed of an object (a pose, a move, its visibility) stayed when the same batch removed it, and the renderer rebuilt for an object it could not find. It goes with the object now.

Still a rebuild: a skinned model the scene has not (its materials and textures load with one), one whose pose mirrors other primitives than the scene's, one added hidden and shown later, one added in a scene with particle systems (the rooms for edits do not grow there, for any edit), and any under software traversal.

Measured

Hardware traversal, a game that spawns a character every half second and takes the oldest away (twelve at most), 16 s:

main this
rebuilds 31 0
a frame that spawns or despawns 46 ms (65 at most) 3.5 ms (4.9 at most)
the longest frame 79 ms 21 ms

The frame between is the same: with eight spawned and then none, at 1280 x 720, the GPU's frame is 10.6 ms either way (the trace 3.5, the BLAS builds 0.58), the builds in turn after a run thrown away.

GPU time a frame at 1080p on twelve scenes, two alternated pairs against main after a run thrown away: all within 0.7 % (the crowd 0.0 and 0.0). The flight over a city in eleven pairs, since it was the one the read cost before the feature: -0.01 % on average (single pairs between -0.8 and +1.0 %). The quality figures against the offline references are main's.

Checks

  • New tests, natively and under software traversal (where each is a rebuild): one added against the CPU skin (triangles, attributes, BLAS input, previous vertices) and a build's picture; its motion vectors at a new pose against a built one's, none longer than the furthest a corner went; moved, hidden, shown; 40 added at once (every room grows), posed on, half hidden and shown; 24 more in a commit that grows the pass's buffers alone; previous vertices kept mesh by mesh (a model removed before a frame is drawn, two whose triangles are neighbours and whose previous vertices are not, one posed twice between frames); one removed and the next added in what it had; a built one removed (shown, hidden, posed in the same batch); the three that rebuild; one added beside a particle system, by a rebuild, the build's posed and removed in place there. The pictures are compared with the build's frames counted from the live view's: a frame's samples go by its number, and at another count a picture of many thin models is two thirds of a step from itself.
  • The unit tests and the render tests, natively and under software traversal, beside main's on the same machine: 214 unit tests pass both ways; 264 render tests natively; under software traversal the 23 that fail on main, and no other.
  • 36 mutations of the new logic: 33 fail a test natively, two under software traversal, and one is equivalent (the CPU's copy of an added model's triangles: a fallback no path reads while the model loads). Eight did not at first: the scenes had no moving triangles before the meshes, motion vectors were compared with a build's alone (wrong alike in both), other rooms grew in every commit that grew the pass's, and no frame was skipped between two edits.
  • Not run on Vulkan yet.

🤖 Generated with Claude Code


Note

High Risk
Touches live GPU scene editing, skinning jobs, motion-vector shaders, and instance records—core rendering path with large benchmark gains but subtle correctness risk around buffer reuse and prev_verts indexing.

Overview
Spawn/despawn characters at runtime without full scene rebuilds. Posed skinned models of assets already in the scene can be added in place (dedicated edit-room mesh, one-time CPU skin for initial pose, GPU skinning job from shared corner data) and removed in place (triangles, records, prev_verts slot, and skin job returned to pools for reuse).

Motion vectors for edit-placed deforming meshes no longer assume previous vertices live in the dynamic-triangle tail. Each instance carries a prev index (also in the GPU record); the path tracer gates the extra lookup behind F_DEFORM when any mesh deforms, avoiding ~0.6% GPU cost on scenes without deformation.

The skinning pass gains SkinGpu::set_job with growable tables/palettes/blocks. Live edits track prev holes and free_skinned slots; keep_prev_spans copies prior-frame vertices per mesh before re-skin. Placed::Skinned wires placement/removal through the edit path.

Fix: removing an object in the same batch now drops co-pending pose/move/visibility changes so the renderer does not rebuild hunting a missing object.

Still requires rebuild: new model assets, mismatched mirror poses, software traversal, particle scenes without edit-room growth, hidden-then-shown adds, etc.

Reviewed by Cursor Bugbot for commit fd86e92. Bugbot is set up for automated code reviews on this repo. Configure here.

yujiaxu-ops and others added 20 commits November 20, 2026 19:28
…hored tangent follows its joints

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A new shared pose sent every triangle of its mesh: 180 bytes each, skinned on the CPU. Now the CPU sends the pose's
matrices and a compute pass skins the mesh from its model's corners: triangles, shading attributes, BLAS input.
The CPU keeps no triangles of such a pose; a click or a query skins the mesh when it asks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Models in the same pose shared one mesh, and one of them taking another pose rebuilt the scene. Now a model's mesh
is its own, skinned by the pass at each new pose: another clip or time is in place whatever the others do, and the
model is hidden and shown in place by its instance.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A posed model the scene did not call movable was moved by skinning it again where it stands. One that is an instance
of a deforming mesh was not moved at all: no pose had changed, and nothing rebuilt. Its move is recorded as a move
now; the renderer moves an instance and skins world-space triangles again.

The test's fixture: 72 triangles (two blocks of the pass), a joint turned about an axis that is neither the
normals' nor the tangents', a node that mirrors its mesh, a clip that turns it back. The test: two model files in
two poses (two sources, two jobs), a model moved alone, posed and moved at once, after the scene's buffers grew,
and a pose that mirrors other primitives.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A mesh's triangles were in its model's order, and first in the GPU's, in every scene the tests had: corners left in
the model's order, and a job counted from the pool's start, passed. The fixture's materials now go light, grey,
light, and the scene has a rect light's card before the meshes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts:
#	renderer/src/live/inplace_tests.rs
…e rebuild

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts:
#	docs/ROADMAP.md
#	renderer/src/gpu.rs
#	renderer/src/live/edits.rs
#	renderer/src/live/mod.rs
#	renderer/src/scene.rs
Its instance is cleared above the triangles and is no object's; its mesh's triangles and its skinning job stay until
the next rebuild, as the build's do. Under software traversal, where it has no instance, a rebuild.

What a batch changed of an object (a pose, a move, its visibility) goes with it when the same batch removes it: the
renderer found nothing to pose and rebuilt.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts:
#	renderer/src/live/inplace_tests.rs
The kernel found them by the triangle's place among the dynamic triangles, which a mesh placed by an edit does not
have. An instance of a mesh that deforms now says where they are (its record's n2.w), and the first hit's motion
reads there. The build puts them where they were.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One of a model the scene has: a mesh of its own in the room, skinned on the CPU once for the pose it comes in, its
previous frame's vertices its own, a job of the skinning pass, which skins it from its next pose on. The pass's
table and the previous vertices' buffer grow with it. One an edit placed gives all of it back when it is removed,
and the next one placed takes it.

A rebuild's still: a skinned model the scene has not, one in a pose that mirrors other primitives than the
scene's, and any under software traversal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A movable card before the meshes (the build's place of a mesh's previous vertices), a bound on every motion vector
(a kernel that reads another triangle's previous vertices agrees with a build that does too), a commit that grows
the skinning pass's buffers alone, previous vertices kept mesh by mesh across commits with no frame between, and
under software traversal a scene with room for triangles.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e of its own

In every kernel it cost a scene without such a mesh 0.6 % of its GPU frame (a flight over a city, five alternated
pairs of five). F_DEFORM is a scene with a mesh that deforms; elsewhere the read is as it was.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops marked this pull request as ready for review November 21, 2026 15:07
The rooms for edits do not grow in a scene with particle systems, and a skinned model added needs room for its
previous vertices: a rebuild there, said so in the roadmap.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops merged commit 23c11b9 into main Nov 21, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the skinned-add-remove branch November 21, 2026 15:21
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