A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(render): a mesh can have 256 joints where 64 imported a rig with fingers and a face as a statue
yhh4cfb06761191
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0cc6b6bca..ffcadfa20 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,8 @@ published separately; it ships inside the editor.- **Glyphs can be put on the atlas before they are shown.** The first page of a novel is hundreds of new characters, all landing in one frame. `preloadGlyphs(app, label, text, { budgetMs })` makes them ahead of time, a slice a frame, drawn as that `Text` will draw them, and returns `progress`, `done` and `release()`. On a Snapdragon 8 Elite a book's 2992 characters at 28 px took 145 ms over 25 frames with the worst frame at 9.5 ms, after which the first page's frame went from 49 to 11 ms and no page made a new glyph. Preloaded glyphs hold their atlas pages (4 MB each, a few hundred characters at that size) until `release()`.- **Voxel GI lights what the camera does not see, and bounces light more than once.** The cache now reads the sun's shadow map back into the world, so a surface the sun lights behind or beside the camera still sends light into the view. Each surface also gives off again the bounce light it received, so a corner or a floor in shade gets light that took two or more bounces to reach it. A ray now brings what it meets at full strength however far it went (it used to fade with distance, 40% at 4 m with 12 cm voxels). Each voxel is weighed by how much of it a surface covers, so a bright patch no longer lights like the whole voxel around it. Together these keep the result close to a path tracer's whatever the voxel size. In a sunlit test room the whole frame carries 0.95 of Cycles' light at the default size and 0.74 at 12 cm voxels; before, it was 0.54 at the default and darker the finer the grid. With the lit patch behind the camera, the walls went from no bounce light to 25–57%. A closed room the sun only lights from outside stays dark. Two inspector controls tune it: **Off-screen Sun Albedo** (the colour the shadow map cannot give, assumed) and **Multi-bounce**. A fine grid no longer drops every voxel: a count truncated by the cache's ageing had kept them below the two samples a ray asks for. The WebGL2 fallback does the same in its own passes: each voxel asks the sun's map whether a sunlit surface stands in it, and traces two rays through last frame's grid for the light it is given. In the test room it carries 1.00 of Cycles' light at the default size (it was 0.56) and 0.80 at 12 cm; with the lit patch behind the camera 0.20 (it was 0). Its voxel pass costs about 1.3 ms more at 720p on a desktop.+- **A mesh can have 256 joints, up from 64.** A rig with fingers, a face and hair no longer imports as a statue. A draw sends only the joints it has, so a small rig costs what it did.+- **A mesh can blend 64 morph targets at once, up from 8.** A face rig holds dozens open at a time. A draw pays only for the targets that are live.- **A foot stands on the ground under it.** A `foot-plant` constraint on an Animator looks down from each foot through physics and bends the leg to land on whatever is there, slopes and steps included, keeping any lift the clip gives it, laying the foot along the slope and lowering the hips so the leg can reach.diff --git a/desktop b/desktopindex 3671fb6ce..bdac6ff3e 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 3671fb6ce6c6b19157f582906d8ebb15e73d2f72+Subproject commit bdac6ff3ead6f37bb6c1399cb80ad30fdc5a3d51diff --git a/docs/astro/src/content/docs/assets/models.mdx b/docs/astro/src/content/docs/assets/models.mdxindex ce375d5f4..0d5855bae 100644--- a/docs/astro/src/content/docs/assets/models.mdx+++ b/docs/astro/src/content/docs/assets/models.mdx@@ -266,7 +266,7 @@ joints.| Limit | Why ||---|---|-| 64 joints per mesh | The pose is a uniform block, which is 4KB at that size — inside what a WebGL2 block is guaranteed. A mesh wanting more draws undeformed. |+| 256 joints per mesh | The pose is a uniform block, which is 16KB at that size — exactly what a WebGL2 block is guaranteed. A draw sends only the joints it has, so a small rig pays nothing for the room. A mesh wanting more draws undeformed. || Joint count must match the bind pose | A mesh whose `MeshSkin` names a different number of joints draws undeformed rather than with vertices resolved against the wrong matrices. |## Morph targetsdiff --git a/docs/astro/src/content/docs/zh-cn/assets/models.mdx b/docs/astro/src/content/docs/zh-cn/assets/models.mdxindex 7e3a0c1af..183e26a6f 100644--- a/docs/astro/src/content/docs/zh-cn/assets/models.mdx+++ b/docs/astro/src/content/docs/zh-cn/assets/models.mdx@@ -230,7 +230,7 @@ mesh 就会变形。| 限制 | 为什么 ||---|---|-| 每个 mesh 最多 64 根骨骼 | 姿态走 uniform 块,64 根是 4KB —— 在 WebGL2 对一个块的保证范围内。超过的 mesh 按不变形绘制。 |+| 每个 mesh 最多 256 根骨骼 | 姿态走 uniform 块,256 根是 16KB —— 正好是 WebGL2 对一个块保证的大小。每次绘制只传它实际有的骨骼,所以小骨架不会为此多付代价。超过的 mesh 按不变形绘制。 || 骨骼数必须与绑定姿态一致 | `MeshSkin` 列出的骨骼数对不上时按不变形绘制,而不是让顶点去解析错误的矩阵。 |## Morph targetdiff --git a/pipeline/src/modeling/rig.ts b/pipeline/src/modeling/rig.tsindex 610013a41..7a0f9a0bb 100644--- a/pipeline/src/modeling/rig.ts+++ b/pipeline/src/modeling/rig.ts@@ -11,7 +11,7 @@import { ANIMATOR_FORMAT_VERSION, PREFAB_FORMAT_VERSION, TIMELINE_FORMAT_VERSION } from 'esengine';import { add, boundsOf, cross, dot, length, normalize, scale, selectFaces, sub, type FaceSelector, type PolyMesh, type Vec3 } from './polyMesh';-export const MAX_RIG_JOINTS = 64;+export const MAX_RIG_JOINTS = 256;const DEG = Math.PI / 180;const SAMPLE_RATE = 30;diff --git a/pipeline/tests/modeling-rig.test.ts b/pipeline/tests/modeling-rig.test.tsindex b98d4a194..88481d215 100644--- a/pipeline/tests/modeling-rig.test.ts+++ b/pipeline/tests/modeling-rig.test.ts@@ -260,8 +260,8 @@ describe('refusals name what to change', () => {expect(() => validateModelSource(source({ rig: { joints: [{ name: 'a', at: [0, 0, 0] }, { name: 'a', at: [0, 1, 0], parent: 'a' }] } }))).toThrow(/two joints called "a"/);expect(() => validateModelSource(source({ rig: { joints: [{ name: 'a/b', at: [0, 0, 0] }] } }))).toThrow(/cannot hold a slash/);expect(() => validateModelSource(source({ rig: { joints: [{ name: 'a', at: [0, 0, 0], bend: 1 }] } }))).toThrow(/unknown field "bend"/);- const many = Array.from({ length: 70 }, (_, i) => ({ name: `j${i}`, at: [0, i, 0], ...(i ? { parent: `j${i - 1}` } : {}) }));- expect(() => validateModelSource(source({ rig: { joints: many } }))).toThrow(/at most 64/);+ const many = Array.from({ length: 260 }, (_, i) => ({ name: `j${i}`, at: [0, i, 0], ...(i ? { parent: `j${i - 1}` } : {}) }));+ expect(() => validateModelSource(source({ rig: { joints: many } }))).toThrow(/at most 256/);});it('clips that do not fit the rig', () => {diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 85bdcd447..aedaf576a 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5905,7 +5905,7 @@ Restart = 1## MESH_MAX_BONES — const @experimental```-64+256```## MIN_CHAIN_POINTS — const @experimentaldiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 6abb72c5e..80f8bbed0 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5913,7 +5913,7 @@ Restart = 1## MESH_MAX_BONES — const @experimental```-64+256```## MIN_CHAIN_POINTS — const @experimentaldiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 8ee81fb43..25ec7db5a 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -5900,7 +5900,7 @@ Restart = 1## MESH_MAX_BONES — const @experimental```-64+256```## MIN_CHAIN_POINTS — const @experimentaldiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex df82ec697..892b944a7 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -5900,7 +5900,7 @@ Restart = 1## MESH_MAX_BONES — const @experimental```-64+256```## MIN_CHAIN_POINTS — const @experimentaldiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 403f7ad8f..8afc6efbd 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -5907,7 +5907,7 @@ Restart = 1## MESH_MAX_BONES — const @experimental```-64+256```## MIN_CHAIN_POINTS — const @experimentaldiff --git a/sdk/src/asset/meshFormat.ts b/sdk/src/asset/meshFormat.tsindex 3fd9e92c8..aa9e31bf9 100644--- a/sdk/src/asset/meshFormat.ts+++ b/sdk/src/asset/meshFormat.ts@@ -38,12 +38,12 @@ const CHANNEL_BYTES = 8;const MATRIX_BYTES = 64;/**- * Joints one draw can be posed by — what the RENDERER holds (64 mat4 is 4KB,- * inside WebGL2's guaranteed block), not what the format carries. A mesh bound+ * Joints one draw can be posed by — what the RENDERER holds (256 mat4 is 16KB,+ * exactly WebGL2's guaranteed block), not what the format carries. A mesh bound* to more is drawn in its bind pose: a joint index no uploaded matrix answers* moves the vertex nowhere in particular. Mirrors GfxEnums.hpp.*/-export const MESH_MAX_BONES = 64;+export const MESH_MAX_BONES = 256;/*** What a channel means. The value IS the shader attribute location, and the firstdiff --git a/src/esengine/data/shaders/mesh.esshader b/src/esengine/data/shaders/mesh.esshaderindex 323a8d418..8deb25123 100644--- a/src/esengine/data/shaders/mesh.esshader+++ b/src/esengine/data/shaders/mesh.esshader@@ -89,7 +89,7 @@ layout(location = 4) in vec4 a_tangent;#ifdef SKINNED// This draw's pose, rewritten immediately before it (SkinConstants, binding 5).layout(std140) uniform SkinConstants {- mat4 u_bones[64];+ mat4 u_bones[256];};#endif@@ -391,7 +391,7 @@ void main() {#pragma vertex wgsl#ifdef SKINNED-struct SkinConstants { bones : array<mat4x4f, 64> };+struct SkinConstants { bones : array<mat4x4f, 256> };@group(0) @binding(5) var<uniform> skin : SkinConstants;#endifdiff --git a/src/esengine/renderer/draw/DrawList.cpp b/src/esengine/renderer/draw/DrawList.cppindex 5d7d46323..6ceb5ac3c 100644--- a/src/esengine/renderer/draw/DrawList.cpp+++ b/src/esengine/renderer/draw/DrawList.cpp@@ -329,7 +329,9 @@ void DrawList::stageBlocks(const PerDrawBlockSet& blocks) {// rather than erasing the last one's, so "unshaped" is an object instead// of an erasure someone has to remember to perform.if (blocks.morph && cmd.morph_index > 0) {- staged.morph = blocks.morph->stage(&morph_shapes_[cmd.morph_index - 1], sizeof(MorphConstants));+ // Only the shapes that are live: the shader reads no further, and the pool lets the next draw start here.+ const MorphConstants& shapes = morph_shapes_[cmd.morph_index - 1];+ staged.morph = blocks.morph->stage(&shapes, static_cast<u32>(sizeof(glm::vec4)) * (1u + static_cast<u32>(shapes.info.x)));}// WHERE this draw's instances read their irradiance, not what it is: thediff --git a/src/esengine/renderer/rhi/GfxEnums.hpp b/src/esengine/renderer/rhi/GfxEnums.hppindex db165b800..2f0763452 100644--- a/src/esengine/renderer/rhi/GfxEnums.hpp+++ b/src/esengine/renderer/rhi/GfxEnums.hpp@@ -126,9 +126,10 @@ static constexpr u32 MESH_INSTANCE_MAX_RECORDS =/// own stream can claim, because it is FRAME state; and the TOP of what remains,/// since a material's textures are handed units upward from unit 8.static constexpr u32 MESH_INSTANCE_TEXTURE_UNIT = 15;-/// Bone matrices one skinned draw may carry. 64 mat4 is 4KB, inside the 16KB a-/// WebGL2 uniform block is guaranteed; a mesh wanting more is drawn static.-static constexpr u32 MESH_MAX_BONES = 64;+/// Bone matrices one skinned draw may carry; a mesh wanting more is drawn static. 256 mat4+/// is exactly the 16KB a WebGL2 uniform block is guaranteed, and a draw stages only the+/// matrices it has, so a small rig pays nothing for the room.+static constexpr u32 MESH_MAX_BONES = 256;/// Morph targets one draw may blend AT ONCE; past it the heaviest are taken. The shader/// loops over only the live ones, each a texture read or two per vertex, so an unused/// budget costs nothing beyond the larger block. Matches the bones: a face runs dozens.diff --git a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hppindex 745cef8df..650888a2e 100644--- a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp+++ b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp@@ -634,7 +634,7 @@ layout(location = 4) in vec4 a_tangent;#ifdef SKINNEDlayout(std140) uniform SkinConstants {- mat4 u_bones[64];+ mat4 u_bones[256];};#endif@@ -936,7 +936,7 @@ void main() {#pragma vertex wgsl#ifdef SKINNED-struct SkinConstants { bones : array<mat4x4f, 64> };+struct SkinConstants { bones : array<mat4x4f, 256> };@group(0) @binding(5) var<uniform> skin : SkinConstants;#endifdiff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 784c836c6..e4f4715ff 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3868,6 +3868,10 @@ export const NOTED = {{"note":"AI agents can build 3D models in the editor from steps."},"feat(mcp): model_write says 64 shapes count at once, and the modeling check proves sixteen do":{"note":"A mesh can blend 64 morph targets at once, up from 8."},+ "feat(render): a mesh can have 256 joints where 64 imported a rig with fingers and a face as a statue":+ {"note":"A mesh can have 256 joints, up from 64."},+ "feat(mcp): model_write takes 256 joints, and the modeling check poses past the old limit":+ {"note":"A mesh can have 256 joints, up from 64."},"feat(render): a draw blends up to 64 morph targets at once, where 8 left a face rig's lighter shapes reading as zero":{"note":"A mesh can blend 64 morph targets at once, up from 8."},"feat(animation): a foot-plant constraint keeps a foot on the physics ground under it, slopes and steps included":