-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShadowNode: Inherit camera.layers only if shadow.camera.layers is not set #30877
base: dev
Are you sure you want to change the base?
ShadowNode: Inherit camera.layers only if shadow.camera.layers is not set #30877
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
src/nodes/lighting/ShadowNode.js
Outdated
@@ -569,7 +569,11 @@ class ShadowNode extends ShadowBaseNode { | |||
const depthVersion = shadowMap.depthTexture.version; | |||
this._depthVersionCached = depthVersion; | |||
|
|||
shadow.camera.layers.mask = camera.layers.mask; | |||
if ( shadow.camera.layers.test( 0 ) === true ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think test()
is expecting a Layer as a parameter instead of a number, it would also be necessary to restore the previous value after rendering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes I forgot layers use so sort of Bit Mask. I guess ( shadow.camera.layers.mask & 0xFFFFFFFE ) === 0
is the right way to check if any layer si set then!
Regarding shadow.camera.layers.mask = camera.layers.mask;
was always here and never restored. I guess I will add it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good now!
shadow.updateMatrices( light ); | ||
|
||
shadow.camera.layers.mask = _shadowCameraLayer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be restored after rendering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, should be good now!
@@ -279,11 +279,22 @@ class TileShadowNode extends ShadowBaseNode { | |||
scene.overrideMaterial = getShadowMaterial( light ); | |||
renderer.setRenderTarget( this.shadowMap ); | |||
|
|||
const cameraLayers = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array object should not be created per update. I suggest you move it into module scope similar to the arrays we use for chain maps.
Fixed: #30156 #30856
Description
Only inherit the camera layers if
shadow.camera.layers
is not set. This allows selective real-time/static shadows and resolves #30156 and #30856. /cc @sunagThis contribution is funded by Renaud Rohlinger @ Utsubo