WebGPURenderer: Use depth32float instead of depth24plus when using reversedDepthBuffer#33184
Conversation
Simplify code.
|
I understand the PR aligns the render target setup with But before merging this, we should find out why Firefox+Windows is the only combination that needs a higher precision. All others don't and this change makes the implementation slower for all these devices. |
…efox-webgpu # Conflicts: # examples/webgpu_reversed_depth_buffer.html
depth32float instead of depth24plus
depth32float instead of depth24plusreversedDepthBuffer: Use depth32float instead of depth24plus
reversedDepthBuffer: Use depth32float instead of depth24plusreversedDepthBuffer: Use depth32float instead of depth24plus
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@Mugen87 I think The following is a quote from https://www.w3.org/TR/webgpu which shows it is implementation-specific:
I just reverted the changes to the reverse-Z example and instead explicitly upped the depth precision when |
|
@Mugen87 I made some changes according to your suggestions, let me know how they look. |
Wouldn't it be better if we had a |
|
I think it's better when the user does not have to worry about the depth texture type. This is rather technical and most users won't get it right. Enabling reverse depth buffer should make the feature work everywhere. #33184 (comment) makes me consider to use Normally a 24 bit depth buffer should be sufficient but there are use cases (like reverse depth buffer) where it obviously doesn't. Also many devices already interpret For now, I would use |
|
Using 32-bit as the default and fallback to 24-bit sounds great if we can do it safely. My concern would be, as you yourself said, that a 24-bit depth buffer might not be sufficient for all use cases. Maybe someone would want to use this without enabling reverse depth; I thought the idea would be similar to If you are confident, let’s move forward, we can change this later if necessary. |
|
@PoseidonEnergy Thank you for working on this! #33184 (comment) is an important insight! |
reversedDepthBuffer: Use depth32float instead of depth24plusdepth32float instead of depth24plus when using reversedDepthBuffer
|
@Mugen87 @PoseidonEnergy @sunag I would really prefer to keep low precision default whenever possible. 8bit is a lot of bandwidth if not needed. Production code as to deal with low end device all the time, also Threejs did it in past with halfFloat everywhere for mobile and it was a very nice approach. |
|
Given that reverse depth buffer requires 32 bit depth, there is no way around I'm afraid. Devices that worked so far already used 32 bit depth. The others are now force so the feature is actually functional. |
Fixed #33166
Description
This PR makes WebGPU use
depth32floatwhenreversedDepthBufferis enabled.Right now,
PassNodecreates aDepthTexturefor its internalRenderTarget, but it leaves the depth texture on the default type. The WebGPU format mapping already supportsDepthFormat + FloatType -> Depth32Float, but the default non-stencil canvas path and the pipeline format query still useDepth24Plus.This fixes the Firefox
webgpu_reversed_depth_bufferz-fighting issue: the example itself already notes that "for best results, a floating-point depth buffer should be used," and explicitly using float depth removes the remaining z-fighting seen in Firefox for the reverse-Z column.