- A node of a model made anew (legacy_flags 0) with a transform gets 0x8000, as a converted one has it: the walk and
posed_transform() left such nodes out, so a skin was drawn off its place in the bind pose (the tube: the upper half 2 m
off) and jumped when an animation set 0x4000 on the joint.
- Normals are skinned by the cofactors of the blended rotation (the direction of its inverse transpose), with the sign of
its determinant, not by the rotation: a joint scaled unevenly tilted the normals of its part.
- rest_pose() takes the translation within the tolerance times the distance from the origin of the mesh and the joints
(palette_scale()): the float chain rounds in proportion to it, and a model a few kilometres out counted as posed in the
bind pose, with a geometry copy and a skinning pass of its own.
Tests: the rest pose far from the origin, the normals of a stretched and of a mirroring joint.
The skinning of stage 4 moved the vertices on the CPU and replaced the geometry of each instance. The Vulkan renderer moves
them in a compute shader now; GL 4.6 stays on the CPU.
- gfx::skin_cache: the walks only work out the palette of the joints; flush(), before the walks of the next frame, moves
the vertices of the instances whose pose changed: through the new GfxRenderer->Skin_Geometry() where the renderer can,
else on the CPU with Replace / Replace_Indexed as before. A chunk made or emptied makes the buffers of the bank anew from
the vertices the CPU holds, so every instance skinned on the GPU is moved again then.
- Vulkan (rendering/vulkan14/vulkan14skinning.cpp, shaders/vk14/skin.comp): the bind pose with the weights of a skinned
part goes to the GPU once, the palette in the ring of the frame; the kernel writes the moved vertices over those of the
chunk of the instance in the buffer of its bank (gfx::basic_vertex), with barriers against the copies of the uploads and
the draws of the frames before, and before the draws of the frame. The vertex buffers of the plain banks get the
storage usage. The kernel is made the first time a part is skinned; without it the CPU moves them.
- eu07.ini: gfx.skinning.gpu (default yes); no moves them on the CPU in Vulkan too. Both give the same picture.
Checked in Vulkan: a tube of two joints turned by 60 degrees, GPU against CPU, with gfx.gpucull 0 and 1: no pixel
differs, and the log shows the kernel ran. Two instances, the second posed later: the first keeps its pose through the
rebuild of the bank, the same as on the CPU. A clip moving the tube every frame. GL 4.6 after the change of the cache:
both instances bent as before (time let run in the editor for the tests only). Unit tests 1200/1200. Not measured on a
large scene, not built with GCC here.
Stage 4 of the EU07M model format. A primitive with a skin (SKIN, SKJT, weights in VSKN or VSKW) was drawn in its bind
pose. Now it follows the joints of its skin, in both renderers.
- The joints are nodes of the model, so they're posed as before: animation events, the .mmd, SetRotate / SetTranslate
from the vehicle code. The matrix of a joint is world(joint) * inverse bind(joint), world being the transform of the
joint from the root of the model with the animations of the instance drawn (TSubModel::posed_transform()); the
vertices lie in the bind pose in the space of the model, the transform of the node of the mesh left out, as in glTF.
- The loader keeps the bind pose and the weights of a skinned primitive (skinning::skinned_geometry on the submodel) and
the skins of the model (TModel3d::skins()).
- The first pass of a frame to draw a skinned submodel of an instance works out the palette and, when it changed, moves
the vertices on the CPU: positions by the blended matrix, normals and tangents by its rotation (model/skinning.cpp,
gfx::skin_cache in rendering/common/skincache.cpp). The geometry of the instance is made or replaced before the passes
of the next frame (flush() in the frame setup of both renderers), as nothing the passes draw may change while they draw
(gfx::walk_sync): the vertices follow the joints a frame late. In the bind pose the shared geometry of the model is
drawn; an instance not drawn for 600 frames lets go of its own.
- Fix: a node with range_max_sq 0, which the spec gives as no limit, was never drawn (a model made anew rather than
converted from E3D); it keeps the default range of a submodel now.
- The editor self-test gets "animate <node> <submodel> <x> <y> <z>", which turns a submodel of an instance as an
animation event does, since the editor doesn't run the events.
Not in this commit: the skinning in a compute shader, bounds of the posed submodel, motion vectors and ray tracing of the
moved vertices.
Checked: a tube of two joints in two instances, one turned by 60 degrees at its middle, bends smoothly while the other
stays straight, in Vulkan and GL 4.6, with gfx.gpucull 0 and 1 (time let run in the editor for the test only). Unit
tests 1194/1194, 5 new ones for the weights, the bind pose, the blending and the file. Not built with GCC here.