-
Notifications
You must be signed in to change notification settings - Fork 369
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
Fix web depth/projection regression, causing incorrect rendering on all 3D scenes #2170
Conversation
fd6e25c
to
c08c123
Compare
// True if we're running on Gles/WebGL. | ||
// (patched accordingly if necessary) | ||
const GLES = false; |
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.
I think something like this would be better:
// True if we're running on Gles/WebGL. | |
// (patched accordingly if necessary) | |
const GLES = false; | |
// True if we're running on Gles/WebGL. | |
// Will be set by `re_renderer` during startup | |
const GLES = ${GLES}; |
That way we cannot accidentally break the patch-code without us noticing it.
…or just pass it in the global uniform buffer
// On GLES/WebGL, the NDC clipspace range for depth is from -1 to 1 and y is flipped. | ||
// wgpu/Naga counteracts this by patching all vertex shader with: |
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.
// On GLES/WebGL, the NDC clipspace range for depth is from -1 to 1 and y is flipped. | |
// wgpu/Naga counteracts this by patching all vertex shader with: | |
// On GLES/WebGL, the NDC clipspace range for depth is from -1 to 1 (and y is flipped). | |
// wgpu/Naga counteracts this by patching all vertex shaders with: |
// This is great, since it means that we can pretend depth is 0 to 1 as specified by WebGPU. | ||
// But it completely messes up depth precision, in particular since we use | ||
// an inverse depth projection that tries to make use of the high float precision closer to zero. | ||
eps *= 1000.0; |
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.
This doesn't seem like an ideal fix. It seems like flipping this around (like the previous PR did) is better for depth precision, just that we also need to flip the Z test?
79983a0
to
7fdca02
Compare
…ll 3D scenes (#2170) * Revert "Fix depth precision issues on WebGL due to different NDC space (#2123)" This reverts commit 4f60fd7. * fudge depth offsets on Webgl * hardware_tier global constant, better depth handling for gles * Improve the depth offset for all platforms --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Reverts
and fixes the issue with a generous depth factor instead.
#2123 didn't make sense: The assumption was that depth range is -1 to 1 on the Web, but if that was true all our clipping would have been wrong. In actuality, wgpu emulates 0 to 1 range for us but this causes precision issues.
Fixes #2166
This also improves the z offset on all platforms
Checklist
PR Build Summary: https://build.rerun.io/pr/2170