-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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: Make material.transparent
behave as in WebGLRenderer
#30862
Conversation
Can also be fixed by changing WebGL backend to behave like WebGPU, but I find the behavior of the WebGL backend more intuitive - it wasn't apparent to me why WebGPU backend would ignore an explicitly set |
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
material.transparent
behave as in WebGLRenderer
Aligning both backends makes of course sense. However, I find the WebGL behavior more confusing. It seems more intuitive to me that blending only works when @WestLangley What is the reason for implementing this aspect in |
@sunag thanks for the fixup! Clarification: It's specifically about the WebGPU backend, WebGPURenderer with Regarding expected behavior, I discovered the mismatch implementing a specific use case where I need blending without moving objects to the second render pass for transparent objects. I see no way to do that with current WebGPU backend. |
How can you ensure that objects are properly sorted for blending if you don't set |
I'm using a full screen pass to draw an overlay on existing opaque geometry, which has to be rendered before other opaque geometry. I'd prefer not to derail the discussion, but focus on the bug and API design instead. Can we agree that there's a legitimate use case to have |
This is exactly what @Mugen87 is doing. The ordering works in reverse to transparent objects, in opaque rendering from closest to furthest for early-z rejection to work in an optimized way which seems like a real problem to me. We need to make sure that users are using the correct approach for each purpose so that the API design is not mistaken for a bug. @Mugen87 Do you remember when we started using three.js/src/renderers/common/RenderList.js Lines 22 to 24 in c92a3ff
|
Using the material ID in I have never seen a performance measurement that has proven the current approach is faster than without using the material ID. I'm also not sure if the current sort is still beneficial for WebGPU. |
Hmm.. I understand that minimizing the overhead of switching shader programs is important, but I think this can be improved, the Another example of what could happen, the sort is based on which material was created last, if you uncomment lines 63 and 64 from the example below you will have a different sort, making the API unstable if Example The idea is to resolve similar objects in the backend itself to minimizing the overhead of switching gpu states, I was developing something in this sense, soon I will continue this work as soon as I resolve some other PRs. This should solve this issue too #30560 |
There are so many issues with this thread... @Mugen87 and @sunag The use of blending does not necessarily have anything to do with transparency. There are a lot of blending functions other than the familiar Porter-Duff formula, which is used to model physical transparency. @rkreis-v You are correct that the WebGLRenderer approach should be followed, but your formula is not quite correct. @sunag In the existing code (prior to this PR), |
@WestLangley Currently the blending was working according to the user's luck creating one material after another as I demonstrated in the fiddle, so |
@sunag My previous comments have nothing to do with sorting. I do not want to get sidetracked here. This PR is about making sure the Please do not assume the use of blending means the material is transparent. Doing so is a misconception. |
It seems like you are linking |
I'm setting |
I'm afraid I still don't understand why Besides, answers to the following questions would also help:
|
@Mugen87 I'm merging, I think we've now fixed This is certainly not compatible with |
@@ -88,7 +88,7 @@ class WebGPUPipelineUtils { | |||
|
|||
let blending; | |||
|
|||
if ( material.transparent === true && material.blending !== NoBlending ) { | |||
if ( material.blending !== NoBlending && ( material.blending !== NormalBlending || material.transparent === true ) ) { |
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.
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.
Updated: 4e3db42
@sunag I think you missed my question in #30862 (comment). Can you please have a look? 🙏 |
Fixed #30861
Description
Make WebGPU backend apply
material.blending
even whenmaterial.transparent
is false, just like WebGL backend.