-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Addons: WebGPU CSM shadows - using shadowNode #29610
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
It seems toggling the |
|
I get the same errors on Chrome WebGL. Appears to be an issue with vec2[4] cascades array. Hardcoding a vec2() rather than cascades.element( n ) in the shader removes the error and is equivalent to how the original PR worked. Looking at the issue at the moment. |
Fix main frustum with WebGL backend.
I have fixed the issue with the WebGL backend and orthographic cameras via b441f99. |
Fading is still broken though. Not sure where the root cause is yet... The |
What is the exact issue with fading? Apart from requiring toggling shadow on and off to get the material to rebuild. |
Fixed up the fading now |
I've revisited the implementation several days now but I can't explain the difference of the shadow frustums so far. I have the feeling the frustums are not correctly transformed for some reasons. |
I think the parameters of shadow camera (I mean |
|
||
csmDirectionalLight.position.set( params.lightX, params.lightY, params.lightZ ).normalize().multiplyScalar( - 200 ); | ||
|
||
csmDirectionalLight.shadow.shadowNode = csm; |
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.
Where does the shadowNode
property get used? I'm trying to figure out if I'm missing something in the TypeScript types for this.
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.
It is used:
const customShadowNode = this.light.shadow.shadowNode; |
As the name suggests it is type Node() but the typescript annotations probably need updating by whoever maintains them.
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.
Thanks! That would be me. :)
Related issue: #29295
CSM implemented using shadowNode.
This uses dummy light objects to use the existing mechanism for updating the cascades shadow cameras, without injecting additional lights into the scene.
The original csm.lightDirection is replaced by the
DirectionalLight
s direction and shadow parameters are inherited from the lights shadow object.This issue where switching between fade and non-fade modes requires triggering a rebuild by disabling and reenabling shadows remains.