Skip to content

Commit 350d1c5

Browse files
WebGPURenderer: Support needsUpdate on shadows (#29110)
1 parent c8f8707 commit 350d1c5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

examples/webgpu_shadowmap_opacity.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
dirLight.shadow.mapSize.height = 2048;
7272
dirLight.shadow.radius = 4;
7373
dirLight.shadow.bias = - 0.0005;
74+
75+
dirLight.shadow.autoUpdate = false;
76+
dirLight.shadow.needsUpdate = true;
77+
7478
scene.add( dirLight );
7579

7680
//

src/nodes/lighting/AnalyticLightNode.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ class AnalyticLightNode extends LightingNode {
267267
const { shadowMap, light } = this;
268268
const { renderer, scene, camera } = frame;
269269

270+
271+
const depthVersion = shadowMap.depthTexture.version;
272+
this._depthVersionCached = depthVersion;
273+
270274
const currentOverrideMaterial = scene.overrideMaterial;
271275

272276
scene.overrideMaterial = overrideMaterial;
@@ -315,7 +319,21 @@ class AnalyticLightNode extends LightingNode {
315319

316320
updateBefore( frame ) {
317321

318-
this.updateShadow( frame );
322+
const shadow = this.light.shadow;
323+
324+
const needsUpdate = shadow.needsUpdate || shadow.autoUpdate;
325+
326+
if ( needsUpdate ) {
327+
328+
this.updateShadow( frame );
329+
330+
if ( this.shadowMap.depthTexture.version === this._depthVersionCached ) {
331+
332+
shadow.needsUpdate = false;
333+
334+
}
335+
336+
}
319337

320338
}
321339

0 commit comments

Comments
 (0)