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: Clear of MRT render targets executed differently in WebGL and WebGPU backend. #30567

Open
WREQI opened this issue Feb 20, 2025 · 7 comments
Labels

Comments

@WREQI
Copy link

WREQI commented Feb 20, 2025

Description

Image

Image

Reproduction steps

  1. open demo url
  2. change forceWebGL param

Code

// code goes here

Live example

https://codesandbox.io/p/devbox/nameless-thunder-qjzqxt?workspaceId=ws_4mXDziRfBeoC3AxqXCn3rR

Screenshots

No response

Version

173

Device

No response

Browser

No response

OS

No response

@WREQI
Copy link
Author

WREQI commented Feb 20, 2025

@mrdoob
Copy link
Owner

mrdoob commented Feb 20, 2025

Do you mean that bloom does overexpose when using the WebGL backend of WebGPURenderer?

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 20, 2025

I'm unable to access the codesandbox. Do you mind sharing the live example as a fiddle (which requires no login)?

Use the following as a starter template: https://jsfiddle.net/mnqr9oj0/

@WREQI
Copy link
Author

WREQI commented Feb 20, 2025

I'm unable to access the codesandbox. Do you mind sharing the live example as a fiddle (which requires no login)?

Use the following as a starter template: https://jsfiddle.net/mnqr9oj0/

https://jsfiddle.net/03b2gy5n/

@WREQI
Copy link
Author

WREQI commented Feb 20, 2025

@Mugen87 There is no difference on a black background, but it will be very bright on a white background
The sharing link above

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 20, 2025

Thanks for sharing the link.

The issue is that the WebGL backend uses the clear color to clear all color attachments whereas the WebGPU backend only clears the first one with the color. The other attachments with { r: 0, g: 0, b: 0, a: 1 }.

for ( let i = 0; i < descriptor.textures.length; i ++ ) {
gl.clearBufferfv( gl.COLOR, i, [ clearColor.r, clearColor.g, clearColor.b, clearColor.a ] );
}

colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };

The behavior of WebGPUBackend seems more correct to me since we never know how additional attachments are configured and if they hold color values or not. Does that sounds reasonable to everyone?

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 20, 2025

At some point we maybe need the ability to define clear values for each attachment 🤔 ?

@Mugen87 Mugen87 added the Bug label Feb 20, 2025
@Mugen87 Mugen87 changed the title Bloom WebGPU Overexposure WebGPURenderer: Clear of MRT render targets executed differently in WebGL and WebGPU backend. Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants