Просмотр исходного кода

ShadowNode: Fix `updateMatrices` sequence (#30064)

* fix `updateMatrices` sequence

* Update webgpu_lights_spotlight.jpg
sunag 1 год назад
Родитель
Сommit
c43288eeff

+ 2 - 0
examples/jsm/csm/CSMShadowNode.js

@@ -75,6 +75,8 @@ class CSMShadowNode extends ShadowBaseNode {
 		for ( let i = 0; i < this.cascades; i ++ ) {
 
 			const lwLight = new LwLight();
+			lwLight.castShadow = true;
+
 			const lShadow = light.shadow.clone();
 			lShadow.bias = lShadow.bias * ( i + 1 );
 

BIN
examples/screenshots/webgpu_lights_spotlight.jpg


+ 5 - 1
src/nodes/accessors/Lights.js

@@ -24,7 +24,11 @@ export function lightShadowMatrix( light ) {
 
 	return data.shadowMatrix || ( data.shadowMatrix = uniform( 'mat4' ).setGroup( renderGroup ).onRenderUpdate( () => {
 
-		light.shadow.updateMatrices( light );
+		if ( light.castShadow !== true ) {
+
+			light.shadow.updateMatrices( light );
+
+		}
 
 		return light.shadow.matrix;
 

+ 3 - 1
src/nodes/lighting/ShadowNode.js

@@ -452,9 +452,11 @@ class ShadowNode extends ShadowBaseNode {
 
 	renderShadow( frame ) {
 
-		const { shadow, shadowMap } = this;
+		const { shadow, shadowMap, light } = this;
 		const { renderer, scene } = frame;
 
+		shadow.updateMatrices( light );
+
 		shadowMap.setSize( shadow.mapSize.width, shadow.mapSize.height );
 
 		renderer.render( scene, shadow.camera );

粤ICP备19079148号