From 428eb72ab58f15f42ac06c61a8bc33fc4cc4bf5c Mon Sep 17 00:00:00 2001 From: sunag Date: Wed, 18 Dec 2024 19:14:09 -0300 Subject: [PATCH] SkinningNode: Fix `previousBoneMatrices` (#30161) * fix previousBoneMatrices * fix no MRT --- src/nodes/accessors/SkinningNode.js | 2 +- src/nodes/lighting/ShadowNode.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nodes/accessors/SkinningNode.js b/src/nodes/accessors/SkinningNode.js index c03c8b5b39f3ca..8337dd2d2b3e0a 100644 --- a/src/nodes/accessors/SkinningNode.js +++ b/src/nodes/accessors/SkinningNode.js @@ -218,7 +218,7 @@ class SkinningNode extends Node { const mrt = builder.renderer.getMRT(); - return mrt && mrt.has( 'velocity' ); + return ( mrt && mrt.has( 'velocity' ) ) || builder.object.userData.useVelocity === true; } diff --git a/src/nodes/lighting/ShadowNode.js b/src/nodes/lighting/ShadowNode.js index 5d6851dcc46c22..d6e549427ebc07 100644 --- a/src/nodes/lighting/ShadowNode.js +++ b/src/nodes/lighting/ShadowNode.js @@ -662,12 +662,21 @@ class ShadowNode extends ShadowBaseNode { const currentRenderObjectFunction = renderer.getRenderObjectFunction(); const currentMRT = renderer.getMRT(); + const useVelocity = currentMRT ? currentMRT.has( 'velocity' ) : false; + renderer.setMRT( null ); renderer.setRenderObjectFunction( ( object, scene, _camera, geometry, material, group, ...params ) => { if ( object.castShadow === true || ( object.receiveShadow && shadowType === VSMShadowMap ) ) { + if ( useVelocity ) { + + object.userData = object.userData || {}; + object.userData.useVelocity = true; + + } + object.onBeforeShadow( renderer, object, camera, shadow.camera, geometry, scene.overrideMaterial, group ); renderer.renderObject( object, scene, _camera, geometry, material, group, ...params );