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

Addons: Port of CSM to WebGPURenderer/Nodes #29515

Closed
wants to merge 1 commit into from

Conversation

aardgoose
Copy link
Contributor

@aardgoose aardgoose commented Sep 27, 2024

Related issue: #29295

Mostly working, the shader isn't rebuilt when switching between fade/non-fade modes without going via no shadow at the moment.

Uses a small addition to DirectionalLightNode to allow a lighting model to be intercepted and provide access to before and after shadow application light properties etc.

A hack is required in AnalyticLightNode to force the setting of the WorldNormal variable outside an 'if' clause.

There are artifact issues which I suspect are the result of using a lower precision depth map than the WebGLRenderer shadow map. Also if the floor casts shadows, it self shadows.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 687.15
170.18
687.15
170.18
+0 B
+0 B
WebGPU 805.48
216.82
805.57
216.85
+91 B
+28 B
WebGPU Nodes 804.99
216.68
805.08
216.71
+91 B
+28 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 462.85
111.79
462.85
111.79
+0 B
+0 B
WebGPU 535.29
144.41
535.38
144.44
+91 B
+28 B
WebGPU Nodes 491.46
134.24
491.55
134.2
+91 B
-35 B

@aardgoose aardgoose changed the title Examples: Port of CSM to WebGPURenderer/Nodes Addons: Port of CSM to WebGPURenderer/Nodes Sep 27, 2024
@sunag sunag added this to the r170 milestone Sep 27, 2024
@sunag
Copy link
Collaborator

sunag commented Oct 1, 2024

The PR is great, but I think we need to think of a solution other than create new lights to get cascades shadows, I think it's a good opportunity to solve the WebGL hacks here.

Perhaps we can think of a class-oriented shadow partitioning system, so that the API is more similar to:

renderer.shadowMap.partitionNode = new CSMNode();

I think fade effect can be implemented for non-cascades shadows too, we have a port for that here.

this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode.rgb.mix( shadowColor, 1 ), shadowIntensity.mul( shadowColor.a ) ) );

Maybe we could start by implementing the fade in another PR, and then the partitioning system in another?

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 10, 2024

Closing in favor of #29610.

@Mugen87 Mugen87 closed this Oct 10, 2024
@Mugen87 Mugen87 removed this from the r170 milestone Oct 10, 2024
@aardgoose aardgoose deleted the csm-lm branch November 6, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants