-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLRenderer: Stable reversed Z buffer implementation. #29579
Conversation
Fix: reset clip state when reset is called Fix: valid depth clear value when reversed is enabled Feat: non-persistent reversedZ state ( can be controlled via renderer.state.buffers.depth.setReversed( )))
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
fix: program parameters
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.
LGTM! Would be great if @CodyJasonBennett could also have a look 👍 .
@CodyJasonBennett can you explain how Looks like needs to change math for it also:
three.js/src/renderers/WebGLRenderer.js Line 2008 in 36bac08
|
You should not use those together. Reverse depth is a strict upgrade and doesn't disable early-z optimizations like logarithmic depth does. I'd expect something is not cleaning up if you see any change to logarithmic depth. |
But by default we can create it together, because capabilities not disable logDepth if we can use reversedZ |
@Mugen87 Perhaps an API change is warranted... THREE.StandardDepthBuffer
THREE.ReversedZDepthBuffer
THREE.LogarithmicDepthBuffer const renderer = new THREE.WebGPURenderer( { depthBuffer: THREE.LogarithmicDepthBuffer } ); |
This is a great suggestion! 👍 |
Indeed! 👍 |
If |
Is it really worth an API change which will not be future proof when exactly reverse-z is opt-in? It is a strict improvement over logarithmic depth where |
FWIW, logarithmic depth already doesn't play nicely with some features (e.g. |
I agree it's better to just have two types of depth buffer implementation and deprecate logarithmic depth buffer in the future. It might still be a good idea to switch to enums instead of using flags since it feels more readable. However, I'm not feeling strong about that. |
Given the recent comments, I am OK with leaving the API as-is. |
Hi @eXponenta, before this PR, reversed Z worked in my simple sandbox app without any changes other than passing the new param to the renderer constructor. However after this PR, my app does not render anything unless I add Could that be due to the removed line that called |
const oldDepth = currentDepthClear; | ||
currentDepthClear = null; | ||
this.setClear( oldDepth ); |
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.
@eXponenta Additionally, maybe we should also do:
const oldFunc = currentDepthFunc;
currentDepthFunc = null;
this.setFunc( oldFunc );
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.
Oops. Yep, this one.
Because we also should upgrade depth func to inverter version.
Fixed #29578
Related PR: #29445
Description
Fix: reset clip state when reset is called
Fix: valid depth clear value when reversed is enabled
Feat: non-persistent reversedZ state ( can be controlled via renderer.state.buffers.depth.setReversed( )))