diff --git a/EngineErrorMap.md b/EngineErrorMap.md index ceb0523c83..259e7e2624 100644 --- a/EngineErrorMap.md +++ b/EngineErrorMap.md @@ -2008,3 +2008,7 @@ Can't getGFXSampler with out device ### 10001 The sub-mesh contains %d vertices, which beyonds the capability (%d vertices most) of renderer of your platform. + +### 10002 + +Sub-mesh may include at most %d morph targets, but you specified %d. diff --git a/cocos/core/assets/morph-rendering.ts b/cocos/core/assets/morph-rendering.ts index 5d739193ce..18acde5ec0 100644 --- a/cocos/core/assets/morph-rendering.ts +++ b/cocos/core/assets/morph-rendering.ts @@ -4,7 +4,7 @@ import { Texture2D } from './texture-2d'; import { ImageAsset } from './image-asset'; import { samplerLib } from '../renderer/core/sampler-lib'; import { UBOMorph, UniformPositionMorphTexture, UniformNormalMorphTexture, UniformTangentMorphTexture } from '../pipeline/define'; -import { warn } from '../platform/debug'; +import { warn, warnID } from '../platform/debug'; import { MorphRendering, SubMeshMorph, Morph, MorphRenderingInstance } from './morph'; import { assertIsNonNullable, assertIsTrue } from '../data/utils/asserts'; import { nextPow2 } from '../math/bits'; @@ -38,6 +38,11 @@ export class StdMorphRendering implements MorphRendering { continue; } + if (subMeshMorph.targets.length > UBOMorph.MAX_MORPH_TARGET_COUNT) { + warnID(10002, UBOMorph.MAX_MORPH_TARGET_COUNT, subMeshMorph.targets.length); + continue; + } + if (preferCpuComputing) { this._subMeshRenderings[iSubMesh] = new CpuComputing( this._mesh,