Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Feb 10, 2025

Fixed #30494.

Description

The PR adds Material.polygonOffset support to the WebGPU backend. The WebGL backend already supports it.

Note: The semantics of polygonOffset in WebGPU are different than in WebGL. When understanding the specs correctly, polygonOffsetUnits should be mapped to depthBias and polygonOffsetFactor to depthBiasSlopeScale. It seems that makes the most sense.

WebGPU: https://www.w3.org/TR/webgpu/#dom-gpudepthstencilstate-depthbias
WebGL: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/polygonOffset

@AndrewChan2022 Would this work for you?

@github-actions
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.42
78.33
336.42
78.33
+0 B
+0 B
WebGPU 517.83
143.85
517.95
143.9
+120 B
+45 B
WebGPU Nodes 517.29
143.74
517.41
143.79
+120 B
+47 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.41
112.17
465.41
112.17
+0 B
+0 B
WebGPU 589.7
160
589.82
160
+120 B
-3 B
WebGPU Nodes 545.07
149.5
545.19
149.54
+120 B
+48 B

@AndrewChan2022
Copy link

Fixed #30494.

Description

The PR adds Material.polygonOffset support to the WebGPU backend. The WebGL backend already supports it.

Note: The semantics of polygonOffset in WebGPU are different than in WebGL. When understanding the specs correctly, polygonOffsetUnits should be mapped to depthBias and polygonOffsetFactor to depthBiasSlopeScale. It seems that makes the most sense.

WebGPU: https://www.w3.org/TR/webgpu/#dom-gpudepthstencilstate-depthbias WebGL: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/polygonOffset

@AndrewChan2022 Would this work for you?

I've tested it, and this is exactly what I wanted. Thanks!

@Mugen87 Mugen87 added this to the r174 milestone Feb 10, 2025
@Mugen87 Mugen87 merged commit 2061c3e into mrdoob:dev Feb 10, 2025
12 checks passed
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.

material.polygonOffset not work when using webgpu version three.js

2 participants