Skip to content

Commit 1aac75a

Browse files
Popov72Mike Bond
authored andcommitted
Fix bones when using vertex pulling
1 parent 85f4325 commit 1aac75a

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

packages/dev/core/src/Rendering/IBLShadows/iblShadowsVoxelRenderer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ export class _IblShadowsVoxelRenderer {
738738
if (axis === 1) {
739739
upDirection = new Vector3(1, 0, 0);
740740
}
741+
mrt.onBeforeRenderObservable.clear();
741742
mrt.onBeforeRenderObservable.add(() => {
742743
voxelMaterial.setMatrix("viewMatrix", Matrix.LookAtLH(cameraPosition, targetPosition, upDirection));
743744
voxelMaterial.setMatrix("invWorldScale", this._invWorldScaleMatrix);

packages/dev/core/src/ShadersWGSL/ShadersInclude/bonesDeclaration.fx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#if NUM_BONE_INFLUENCERS > 0
2-
attribute matricesIndices : vec4<f32>;
3-
attribute matricesWeights : vec4<f32>;
2+
attribute matricesIndices : vec4f;
3+
attribute matricesWeights : vec4f;
44
#if NUM_BONE_INFLUENCERS > 4
5-
attribute matricesIndicesExtra : vec4<f32>;
6-
attribute matricesWeightsExtra : vec4<f32>;
5+
attribute matricesIndicesExtra : vec4f;
6+
attribute matricesWeightsExtra : vec4f;
77
#endif
88

99
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE

packages/dev/core/src/ShadersWGSL/iblVoxelGrid.vertex.fx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <bakedVertexAnimationDeclaration>
2-
#include <bonesDeclaration>
2+
#include <bonesDeclaration>(attribute matricesIndices : vec4f;,,attribute matricesWeights : vec4f;,,attribute matricesIndicesExtra : vec4f;,,attribute matricesWeightsExtra : vec4f;,)
33
#include <helperFunctions>
44
#include <instancesDeclaration>
55

@@ -13,7 +13,15 @@
1313
#ifdef VERTEX_PULLING_USE_INDEX_BUFFER
1414
var<storage, read> indices : array<u32>;
1515
#endif
16-
var<storage, read> position : array<f32>;
16+
var<storage, read> position : array<vec3f>;
17+
#if NUM_BONE_INFLUENCERS > 0
18+
var<storage, read> matricesIndices : array<vec4f>;
19+
var<storage, read> matricesWeights : array<vec4f>;
20+
#if NUM_BONE_INFLUENCERS > 4
21+
var<storage, read> matricesIndicesExtra : array<vec4f>;
22+
var<storage, read> matricesWeightsExtra : array<vec4f>;
23+
#endif
24+
#endif
1725

1826
uniform world : mat4x4f;
1927
uniform invWorldScale: mat4x4f;
@@ -86,7 +94,16 @@ let inputPosition: vec3f = positionUpdated;
8694
#include <instancesVertex>
8795

8896
#include <bakedVertexAnimation>
89-
#include <bonesVertex>
97+
98+
#if NUM_BONE_INFLUENCERS > 0
99+
let matrixIndex = matricesIndices[vertIdx];
100+
let matrixWeight = matricesWeights[vertIdx];
101+
#if NUM_BONE_INFLUENCERS > 4
102+
let matrixIndexExtra = matricesIndicesExtra[vertIdx];
103+
let matrixWeightExtra = matricesWeightsExtra[vertIdx];
104+
#endif
105+
#endif
106+
#include <bonesVertex>(vertexInputs.matricesIndices,matrixIndex,vertexInputs.matricesWeights,matrixWeight)
90107

91108
let worldPos = finalWorld * vec4f(positionUpdated, 1.0);
92109

0 commit comments

Comments
 (0)