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: Align depth range of WebGPU and WebGL backends #28065

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Apr 4, 2024

Description
When overriding the depthPixelBase, both backends display different behaviors related to their distinct depth ranges, with WebGPU being [0, 1] and WebGL being [-1, 1].

It seems that without extensions such as EXT_depth_clamp, WebGL internally clamps these values to the range [0, 1] during the rasterization process. So, I believe that it wouldn't be wrong to handle it internally, ensuring that if a user overrides the depth of a material, both backends will show the same result.

Edit: Or should we do the opposite and handle WebGL depth range first? I'm not sure, it seems that the case is very variable on if we want to handle it manually. For example the issue I was solving there was that using 0.5 * modelViewMatrix.z / modelViewMatrix.w + 0.5 breaks in WebGPU as it should be modelViewMatrix.z / modelViewMatrix.w.

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger changed the title WebGPURenderer: Align depth of WebGPU and WebGL backends WebGPURenderer: Align depth range of WebGPU and WebGL backends Apr 4, 2024
@RenaudRohlinger RenaudRohlinger marked this pull request as draft April 4, 2024 06:19
@sunag
Copy link
Collaborator

sunag commented Apr 5, 2024

Edit: Or should we do the opposite and handle WebGL depth range first? I'm not sure, it seems that the case is very variable on if we want to handle it manually. For example the issue I was solving there was that using 0.5 * modelViewMatrix.z / modelViewMatrix.w + 0.5 breaks in WebGPU as it should be modelViewMatrix.z / modelViewMatrix.w.

The WebGPU specifications will always be the basis for all WebGL variations in WebGPURenderer, for this your current implementation seems correct to me. I was just wondering, according to the explanation, can we use the EXT_depth_clamp extension and check if it is not available in setup() and then apply the path?

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.

None yet

2 participants