-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
base: dev
Are you sure you want to change the base?
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 |
import { reference, uniform, int, float, vec4, vec2, If, Fn, min, renderGroup, positionView, Node, NodeUpdateType, shadow } from 'three/tsl'; | ||
|
||
const _cameraToLightMatrix = new Matrix4(); | ||
const _lightSpaceFrustum = new CSMFrustum(); |
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 you must create CSMFrustum
depending on the backend. Otherwise the result is incorrect for WebGL since the internal vertices are not correctly configured.
csmDirectionalLight.shadow.mapSize.width = 1024; | ||
csmDirectionalLight.shadow.mapSize.height = 1024; | ||
csmDirectionalLight.shadow.camera.near = 1; | ||
csmDirectionalLight.shadow.camera.far = 20000; |
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.
Why did you pick this extreme far
value? I would expect using 1000
(params.far
).
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.