You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
RenaudRohlinger
changed the title
WebGPURenderer: Align depth of WebGPU and WebGL backends
WebGPURenderer: Align depth range of WebGPU and WebGL backends
Apr 4, 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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.5breaks in WebGPU as it should bemodelViewMatrix.z / modelViewMatrix.w.This contribution is funded by Utsubo