-
-
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
Avoid console warnings when using WebXR Layers #22145
Conversation
|
||
needsUpdate = true; | ||
|
||
} // else avoid https://github.com/mrdoob/three.js/issues/22079 when using XR layers. |
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.
Can you explain in more detail why this fixes the mentioned warnings? TBH, I understand the change so far.
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'm not sure of the exact flow. But I think the issue is that the system is trying to draw to _gl.BACK
when using XR Layers rather than to the WebXR compositor's provided texture. I thought this would result in an error and a black frame since the draw calls would not be sent to the WebXR compositor's render target, but it only seems to be a warning.
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.
Sorry, I can't approve this PR without a closer study of the code. One should also clarify if this is an issue in Oculus Browser.
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.
That's understandable. I restricted the code as much as possible so that it only affects devices with layers. At the moment, that's limited to Oculus Browser so there is no other way to test this.
Another option might be to set renderTarget
when in WebXR or when layers are active. That would cause the code to go through the if ( renderTarget ) {
path above this change. I'll try making that change and see if the results are the same.
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.
The specific issue is that drawBuffers([gl.BACK])
is only valid for the default framebuffer that you get from bindFramebuffer(..., null)
. However, in WebXR mode, state.bindFramebuffer(..., null)
has an override to replace the default framebuffer with the XR framebuffer which is a framebuffer object, and that should use [gl.COLOR_ATTACHMENT0]
and not override with [gl.BACK]
.
This is a general issue that happens when switching render targets while in XR, so it's not specific to WebXR Layers. It also happens when rendering shadows in phone AR mode.
See google/model-viewer#2769 (reply in thread) which has some more details from where I investigated this for model-viewer.
Adding a "is in XR" conditional here would work, but alternatively would it make sense to move the low-level drawBuffers
call to WebGLState and apply an override there that replaces gl.BACK
with gl.COLOR_ATTACHMENT0
when xrFramebuffer is active?
Discarding this change in favor of #22558 |
Fixes #22079
Tested: