Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class ComputeShaderBoundingHelper implements IBoundingInfoHelperPlatform
);

ubo.updateFloat3("morphTargetTextureInfo", manager._textureVertexStride, manager._textureWidth, manager._textureHeight);
ubo.updateInt("morphTargetCount", manager.numInfluencers);
ubo.updateFloat("morphTargetCount", manager.numInfluencers);
ubo.update();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class MorphTargetsBlock extends NodeMaterialBlock {
const uniformsPrefix = isWebGPU ? "uniforms." : "";
if (manager?.isUsingTextureForTargets) {
injectionCode += `for (${isWebGPU ? "var" : "int"} i = 0; i < NUM_MORPH_INFLUENCERS; i++) {\n`;
injectionCode += `if (i >= ${uniformsPrefix}morphTargetCount) { break; }\n`;
injectionCode += `if (${isWebGPU ? "f32" : "float"}(i) >= ${uniformsPrefix}morphTargetCount) { break; }\n`;

injectionCode += `vertexID = ${isWebGPU ? "f32(vertexInputs.vertexIndex" : "float(gl_VertexID"}) * ${uniformsPrefix}morphTargetTextureInfo.x;\n`;
if (supportPositions) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Morph/morphTargetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class MorphTargetManager implements IDisposable {
effect.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight);
effect.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices);
effect.setTexture("morphTargets", this._targetStoreTexture);
effect.setInt("morphTargetCount", this.numInfluencers);
effect.setFloat("morphTargetCount", this.numInfluencers);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifdef MORPHTARGETS_TEXTURE
#if {X} == 0
for (int i = 0; i < NUM_MORPH_INFLUENCERS; i++) {
if (i >= morphTargetCount) break;
if (float(i) >= morphTargetCount) break;

vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
attribute vec4 color{X};
#endif
#elif {X} == 0
uniform int morphTargetCount;
uniform float morphTargetCount;
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifdef MORPHTARGETS_TEXTURE
#if {X} == 0
for (var i = 0; i < NUM_MORPH_INFLUENCERS; i = i + 1) {
if (i >= uniforms.morphTargetCount) {
if (f32(i) >= uniforms.morphTargetCount) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
attribute color{X} : vec4<f32>;
#endif
#elif {X} == 0
uniform morphTargetCount: i32;
uniform morphTargetCount: f32;
#endif
#endif
4 changes: 2 additions & 2 deletions packages/dev/core/src/ShadersWGSL/boundingInfo.compute.fx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const identity = mat4x4f(

struct Settings {
morphTargetTextureInfo: vec3f,
morphTargetCount: i32,
morphTargetCount: f32,
indexResult : u32,
};

Expand Down Expand Up @@ -165,7 +165,7 @@ fn main(@builtin(global_invocation_id) global_id : vec3<u32>) {

#ifdef MORPHTARGETS
for (var i = 0; i < NUM_MORPH_INFLUENCERS; i = i + 1) {
if (i >= settings.morphTargetCount) {
if (f32(i) >= settings.morphTargetCount) {
break;
}
positionUpdated = positionUpdated + (readVector3FromRawSampler(i, index) - position) * morphTargetInfluences[i];
Expand Down