Skip to content

WebGPURenderer: Add clipping + stencil demo. - #34325

Merged
Mugen87 merged 1 commit into
mrdoob:devfrom
Mugen87:dev4
Aug 21, 2026
Merged

Mugen87 merged 1 commit into
mrdoob:devfrom
Mugen87:dev4

Conversation

@Mugen87

@Mugen87 Mugen87 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Fixed #34315.

Description

The PR adds webgpu_clipping_stencil to demonstrate the combination of clipping planes + stencil.

The demo was not functional without multiple bug fixes.

  • ClippingContext must put an ID into its cache key. Even if the number of clipping planes are equal, different context should not share a node builder state since they provide different uniform data. We could update clipping uniforms per object, but that ends up more expensive than the ID solution.
  • Stencil wasn't properly cleared in the WebGL backend.
  • The hardware clipping state in WebGL wasn't properly managed.

@Mugen87 Mugen87 added this to the r186 milestone Aug 21, 2026
@github-actions

Copy link
Copy Markdown

πŸ“¦ Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 372.43
87.92
372.43
87.92
+0 B
+0 B
WebGPU 700.2
193.18
700.29
193.21
+98 B
+23 B
WebGPU Nodes 698.18
192.87
698.28
192.9
+98 B
+28 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 515.85
124.88
515.85
124.88
+0 B
+0 B
WebGPU 774.19
207.91
774.29
207.94
+98 B
+29 B
WebGPU Nodes 723.15
195.25
723.25
195.27
+98 B
+29 B

@Mugen87
Mugen87 merged commit 00ea66e into mrdoob:dev Aug 21, 2026
9 checks passed
@WestLangley

Copy link
Copy Markdown
Collaborator

@Mugen87 I think the shadows of the exposed faces due to clipping are incorrect when a clipping plane is negated. The same issue occurs in the WebGLRenderer example. Can you check to see if you agree? It is subtle.

@Mugen87

Mugen87 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

exposed faces

Do you mean the red ones? If so, it looks like they are missing when negated is checked.

@WestLangley

Copy link
Copy Markdown
Collaborator

Exactly.

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.

WebGPU_clip_stencil_issue

2 participants