Commit Graph

1983 Commits

Author SHA1 Message Date
cptbtptpbcptdtptp
2d3b2d4526 chore: release v0.0.0-experimental-2.0-game.4 2026-04-23 21:08:05 +08:00
shensi.zxd
e63413425b fix(shader): scan instance uniforms with macro awareness for raw GLSL
cherry-pick from galacean/engine#2957 commit 29567302

compilePlatformSource 路径中 #ifdef 块未展开就执行 _scanInstanceUniforms,
导致非活跃分支内的 renderer_JointMatrix 被正则命中报错。

- compilePlatformSource 构建 activeMacros 传入 injectInstanceUBO
- 新增 _scanInstanceUniformsWithMacros,逐行追踪 #ifdef/#ifndef/#else/#endif
- array uniform 从 return "" 改为 return match(保留为普通 uniform)
2026-04-23 21:00:12 +08:00
cptbtptpbcptdtptp
77ce2c6bde Merge branch 'fix/shaderlab' of github.com:galacean/runtime into fix/shaderlab 2026-04-23 18:09:36 +08:00
cptbtptpbcptdtptp
7c2ed5906d feat: atlas support rotate 2026-04-23 18:08:29 +08:00
shensi.zxd
dd02420acc feat(core): GPU Instancing 自动合批(cherry-pick from galacean/engine#2957)
从 PR https://github.com/galacean/engine/pull/2957 (feat/gpu-instancing)
cherry-pick 69 个 commit 到 fix/shaderlab 分支,压缩为单次提交。

## 核心改动

### 新增文件
- `InstanceBuffer.ts` — UBO-based 实例数据管理,将多个 renderer 的
  worldMatrix/shaderData 打包到一个 UBO 中
- `VertexMergeBatcher.ts` — 替代旧 BatchUtils,统一 2D/3D 合批入口
- `ShaderBlockProperty.ts` — UBO block 属性描述
- `ShaderProgramMap.ts` — 替代旧 ShaderProgramPool,支持 instancing layout 缓存
- `ConstantBufferBindingPoint.ts` — UBO binding point 枚举

### 修改文件
- `MeshRenderer._canBatch/_batch` — 同 mesh+material+macros 自动合批判定
- `SkinnedMeshRenderer` — 标记不可 GPU instance
- `RenderQueue` — 按 material/primitive 排序(替代按距离排序),
  渲染时检测 instanced batch 并通过 InstanceBuffer 一次 draw
- `RenderElement` — 扁平化(移除 SubRenderElement),支持 instancedRenderers 列表
- `ShaderFactory` — UBO 布局计算、instancing GLSL 注入(RENDERER_GPU_INSTANCE macro)
- `ShaderPass` — 编译时检测 GPU instance macro,注入 UBO 声明
- `ShaderProgram` — 存储 instanceLayout
- `Renderer` — 移除 batched 相关字段

### 删除文件
- `BatchUtils.ts` → 替换为 `VertexMergeBatcher.ts`
- `SubRenderElement.ts` → 合并到 `RenderElement.ts`
- `ShaderProgramPool.ts` → 替换为 `ShaderProgramMap.ts`

## cherry-pick 冲突解决记录

fix/shaderlab 分支和 PR 基线 (dev/2.0) 的差异主要在以下文件:

1. **ShaderPass.ts** — fix/shaderlab 使用 `Shader._shaderLab._parseMacros`
   处理 ShaderLab 宏,而 PR 使用 `ShaderMacroProcessor.evaluate`(fix/shaderlab
   上不存在)。解决方式:保留 fix/shaderlab 的宏处理,加入 PR 的 instancing
   UBO 注入逻辑。
2. **Transform.glsl** — fix/shaderlab 已有 `camera_VPMat` 声明,PR 也添加了。
   解决方式:合并两边声明。
3. **UIRenderer.ts** — PR 将 `BatchUtils` 重命名为 `VertexMergeBatcher`,
   `batchFor2D` 重命名为 `batch`。fix/shaderlab 的 UI 包未同步。
   解决方式:手动更新 UI 包的 import 和调用。
4. **GLSLIfdefResolver.ts** — PR 早期 commit 新增此文件,后续 commit 删除。
   cherry-pick 后 ShaderPass.ts 残留了 import。解决方式:删除无用 import。

## 验证结果

CarParking 游戏 DrawCall 从 905 降至 ~80(同 mesh+material 的座椅、轮子等
自动合批)。
2026-04-23 17:26:31 +08:00
cptbtptpbcptdtptp
27fbf5f5f6 chore: release v0.0.0-experimental-2.0-game.3 2026-04-22 21:56:02 +08:00
cptbtptpbcptdtptp
cc0cb66269 Merge remote-tracking branch 'origin/fix/shaderlab' into fix/shaderlab 2026-04-22 21:54:09 +08:00
luzhuang
14407d9dd2 fix(audio): restore pending playback correctly 2026-04-22 21:52:03 +08:00
cptbtptpbcptdtptp
ecd794435f Merge remote-tracking branch 'origin/fix/shaderlab' into fix/shaderlab 2026-04-22 21:29:51 +08:00
cptbtptpbcptdtptp
dcae1d7847 fix: opt get sprites error 2026-04-22 21:28:56 +08:00
luzhuang
599a7e6119 fix(core): evict active scene asset cache on loadScene to avoid self-destroy
When loadScene is called with a URL whose cached Scene is the current active
scene, resourceManager.load returned the same instance, then destroyOldScene
branch destroyed it and re-added it—leaving rootEntities empty and the native
PhysicsScene released. Now evict the cached Scene asset before load so a fresh
Scene instance is created, matching director.loadScene semantics in Cocos.
2026-04-22 20:06:11 +08:00
chenmo.gl
83f6657bf4 Merge branch 'fix/shaderlab' of https://github.com/galacean/engine into fix/shaderlab 2026-04-22 19:52:02 +08:00
chenmo.gl
569c062a24 fix(entity): remove redundant self-name prefix check in _findChildByName method 2026-04-22 19:45:27 +08:00
cptbtptpbcptdtptp
60e963728a fix: clear children bug 2026-04-22 19:24:47 +08:00
cptbtptpbcptdtptp
ae8c7db08d chore: release v0.0.0-experimental-2.0-game.1 2026-04-21 17:40:01 +08:00
cptbtptpbcptdtptp
b16d8b5d75 fix(core): invoke structured Signal listeners with runtime args before bound args
Previously `Signal._addListener` applied bound arguments first and runtime
signal args last, producing `method(...boundArgs, ...signalArgs)`. This made
the event object's position shift with the number of bound arguments and
diverged from the DOM / Cocos `(event, customEventData)` convention.

Flip the order so the listener method receives runtime args first and bound
args last: `method(...signalArgs, ...boundArgs)`. The event object now always
sits at index 0, making migrated Cocos scripts with `(event, customData)`
signatures work without rewrites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 17:31:35 +08:00
cptbtptpbcptdtptp
e5228d76d6 chore: release v0.0.0-experimental-2.0-game 2026-04-21 14:58:33 +08:00
luzhuang
acf9c2d70e fix(core/ui): propagate reparent dirty to descendants in Transform and UITransform (#2973) 2026-04-21 14:54:24 +08:00
cptbtptpbcptdtptp
3075f4f85b fix: entity set sibling error when without parent 2026-04-20 15:58:33 +08:00
luzhuang
bdf54903bf fix(physics-physx): raycast 和 sweep 跳过 initial overlap
PhysX 射线/sweep 起点在碰撞体内部时会返回 distance=0 的命中,
与 Unity 行为不一致。通过启用 POST_FILTER 并在 postFilter 中
过滤 distance<=0 的结果,使 PhysX 跳过 initial overlap 并继续
查找下一个最近命中。

- 启用 POST_FILTER query flag
- raycast 和 sweep callback 添加 postFilter 过滤 distance<=0
- 更新 PhysX wasm CDN URL(对应 QueryBinding.h postFilter 改动)
- 更新本地 wasm 产物
2026-04-15 21:20:49 +08:00
luzhuang
d5b6dd9012 fix(loader): add audio extension to AudioLoader supported types 2026-04-15 19:44:32 +08:00
cptbtptpbcptdtptp
bc35a612eb fix: revert code 2026-04-15 19:43:52 +08:00
cptbtptpbcptdtptp
5d7e6af705 Merge remote-tracking branch 'origin/fix/shaderlab' into fix/shaderlab 2026-04-15 19:38:54 +08:00
cptbtptpbcptdtptp
f5be42400b fix: raycast and clone 2026-04-15 19:38:17 +08:00
luzhuang
069f182a86 fix(loader): normalize gltf wrapper and skin roots 2026-04-15 17:39:05 +08:00
luzhuang
b3bf58a816 Revert "fix(loader): restore single-root GLTF scene without GLTF_ROOT wrapper"
This reverts commit 8a86f279eca9b2bc4a2fa56f94f174236f9a5674.
2026-04-15 17:39:04 +08:00
luzhuang
5abb3f5f02 fix(loader): restore single-root GLTF scene without GLTF_ROOT wrapper
Single-root GLTF scenes no longer wrap the root node in a GLTF_ROOT
container, which avoids redundant nesting and fixes animation path
resolution for models like Mixamo characters.

- GLTFSceneParser: single-root scenes use the node directly as scene root
- GLTFAnimationParser: remove single-root path prefixing (no longer needed)
- Entity.findByPath: prefer real same-name child over legacy self-name prefix
- Add AGENTS.md to .gitignore
2026-04-15 17:39:03 +08:00
luzhuang
3071f908c8 fix(loader): always create GLTF_ROOT container for consistent animation paths (#2942)
Remove single-root vs multi-root branching in GLTFSceneParser, always
creating a GLTF_ROOT wrapper entity. This ensures animation bone paths
are consistent across different glTF files, fixing cross-file animation
clip retargeting.
2026-04-15 17:39:01 +08:00
shensi.zxd
4fe4fae272 fix(shader): add missing camera_VPMat declaration in Transform.glsl 2026-04-15 16:48:27 +08:00
cptbtptpbcptdtptp
40006d952f fix: raycast collider layer 2026-04-15 16:37:08 +08:00
cptbtptpbcptdtptp
5c2edee1ec fix: clone and sibling index 2026-04-15 15:12:58 +08:00
cptbtptpbcptdtptp
ca5252a9a8 feat: supported filled 2026-04-07 16:21:59 +08:00
cptbtptpbcptdtptp
207a3811b1 feat(2d): add FilledSpriteAssembler and sprite filled mode support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 16:37:45 +08:00
luzhuang
15b19affcd feat: particle bug not fix 2026-04-01 12:09:30 +08:00
luzhuang
13052d2f98 feat(ui): add SpriteSizeMode to Image component
When sizeMode is set to Automatic, the UITransform size is automatically
synchronized to the sprite's natural dimensions when the sprite changes.
This matches Cocos Creator's Sprite.SizeMode.TRIMMED behavior.

- Add SpriteSizeMode enum (Custom / Automatic)
- Add sizeMode property to Image with getter/setter
- Sync UITransform.size in set sprite and _onSpriteChange
- Export SpriteSizeMode from component index
2026-03-30 14:59:53 +08:00
luzhuang
63c715b635 fix(animation): add per-instance speed to AnimatorStatePlayData
AnimatorState.speed is part of the shared AnimatorController asset.
Modifying it at runtime pollutes all Animator instances sharing the
same controller, causing animation speed corruption after cloning.

- Add speed field to AnimatorStatePlayData, initialized from AnimatorState.speed on reset
- Add proxy properties (name/clip/wrapMode/transitions/addStateMachineScript)
- Change speed calculation to playData.speed * animator.speed
- findAnimatorState now returns per-instance AnimatorStatePlayData
- Export AnimatorStatePlayData for consumer code
2026-03-30 14:50:22 +08:00
luzhuang
d9a267477d fix(animation): normalize single-root clip binding paths 2026-03-29 20:56:45 +08:00
luzhuang
a6156ba9fb fix(clone): prefab 克隆时自动 deep clone 同类型 Object 属性,防止共享状态
CloneManager: 当 source 和 target 属性是同类型 Object 实例(如 Vector4)时,
自动升级为 DeepClone,避免 prefab 模板的引用覆盖克隆体的独立实例。
新增 Map/Set 类型的 deep clone 支持。

ModelMesh: throw string 改为 throw Error 以获得正确堆栈。
2026-03-29 19:02:38 +08:00
luzhuang
13521cc420 fix(loader): componentRef 解析支持 clone entity 子树查找
ReflectionParser 解析 IComponentRef(entityPath + componentType)时,
目标组件可能在 GLB clone 的子 entity 上而非 clone 根 entity 自身。
getComponents 找不到时 fallback 到 getComponentsIncludeChildren。
2026-03-29 18:53:54 +08:00
cptbtptpbcptdtptp
ca0d518383 fix: use project type 2026-03-28 18:45:43 +08:00
cptbtptpbcptdtptp
41f024e1f8 fix(camera): make invViewProjMat ignore scale consistently with viewMatrix
The viewMatrix getter intentionally ignores the camera entity's world scale
(using Matrix.rotationTranslation), but _getInvViewProjMat() was using the
full entity.transform.worldMatrix which includes inherited scale. This
inconsistency causes screenPointToRay to produce incorrect world-space rays
when the camera inherits scale from a parent entity (e.g. UICanvas in
ScreenSpaceCamera mode with camera as a child of canvas).

Closes #2748

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 14:38:55 +08:00
shensi.zxd
3cf18831d4 fix(shader-lab): allow logical NOT operator on numeric operands in preprocessor
#if !0 and similar expressions now work correctly, matching C/GLSL preprocessor behavior.
2026-03-27 17:55:51 +08:00
cptbtptpbcptdtptp
d0dada8e52 fix: keep mesh data 2026-03-27 15:17:06 +08:00
cptbtptpbcptdtptp
c662731f2f fix: entity disable 2026-03-27 15:12:36 +08:00
cptbtptpbcptdtptp
1749077779 fix: temp 2026-03-27 12:14:57 +08:00
cptbtptpbcptdtptp
b7146090d3 fix: temp 2026-03-27 10:59:04 +08:00
shensi.zxd
bfe4e9ea23 fix(shader-lab): add missing semicolon in GLES100 fragment return conversion
GLES100 visitJumpStatement converted `return expr;` to `gl_FragColor = expr`
without a trailing semicolon, causing WebGL compilation errors. Only triggered
when fragment entry returns vec4 (Cocos pattern), not void (standard Galacean).
2026-03-27 01:06:15 +08:00
shensi.zxd
80e6e3ebb3 fix(shader-lab): handle global struct-typed variables and simplify macro scanning
- Suppress `uniform` output for global struct-typed variables (e.g. `Varyings o;`)
- Register global struct vars in both per-function and cross-stage maps
- Unify macro member access scanning into callback-based _forEachMacroMemberAccess
- Add registerStructVar() encapsulation in VisitorContext
- Add Cocos VSOutput pattern test (global-varying-var)
2026-03-27 00:33:21 +08:00
shensi.zxd
828752de06 fix(shader-lab): skip type inference for member access macros in semantic analysis 2026-03-26 23:15:39 +08:00
shensi.zxd
d05187b7fc fix(shader-lab): support global #define with cross-stage struct var transform
Build a combined _globalStructVarMap in visitShaderProgram by scanning
both vertex and fragment entry functions, so global #define values like
`attr.POSITION` or `o.v_uv` are correctly transformed in all stages.

Rewrite define-struct-access tests to use snapshot file comparison
against expected/ GLSL outputs for clearer verification.
2026-03-26 23:13:18 +08:00