Skip to content
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

WebGPURenderer: Manual Shadow Update Control via shadow.needsUpdate #29110

Merged
merged 2 commits into from
Aug 10, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

Description
This PR allows to manually control the update of a shadow through the already available shadow.autoUpdate and shadow.needsUpdate properties.

Usage:

const dirLight = new THREE.DirectionalLight( 0xffffff, 10 );
dirLight.castShadow = true;
dirLight.shadow.autoUpdate = false;
dirLight.shadow.needsUpdate = true;

To demonstrate the feature, I updated the webgpu_shadowmap_opacity example:

Before:
Screenshot 2024-08-10 at 23 32 39

After:
Screenshot 2024-08-10 at 23 31 33

To ensure this feature works correctly, I had to account for the versioning of depthTexture. Without this, when the Renderer initialize the FBO in the first render loop, it updates the attached textures, leading to the incorrect shadowMap being bound to the meshes in subsequent renders.

This contribution is funded by Utsubo

Copy link

github-actions bot commented Aug 10, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
685.1 kB (169.6 kB) 685.1 kB (169.6 kB) +0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
462 kB (111.4 kB) 462 kB (111.4 kB) +0 B

@RenaudRohlinger RenaudRohlinger added this to the r168 milestone Aug 10, 2024
@sunag
Copy link
Collaborator

sunag commented Aug 10, 2024

We could consider it to be the default if it is in a static group.

@sunag sunag merged commit 350d1c5 into mrdoob:dev Aug 10, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants