Skip to content
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

WebGLBackground: renderer.autoClear has no effect when an XR session is active #25955

Closed
mrxz opened this issue Apr 28, 2023 · 1 comment · Fixed by #26428
Closed

WebGLBackground: renderer.autoClear has no effect when an XR session is active #25955

mrxz opened this issue Apr 28, 2023 · 1 comment · Fixed by #26428
Milestone

Comments

@mrxz
Copy link
Contributor

mrxz commented Apr 28, 2023

Description

Since r152 the renderer.autoClear flag is effectively ignored when in an XR session. This seems to be a result of changes made as part of #25781. The code in WebGLBackground now force clears if there is an XR session.

Relevant code: https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLBackground.js#L47-L66
(note that the switch case is exhaustive as per WebXR spec, and all cases set forceClear)

This causes a problem when the frame is rendered using multiple renderer.render() calls. Setting renderer.autoClear = false no longer suffices in that case. It can be worked around by setting the individual autoClearColor, autoClearDepth and autoClearStencil, as these are still honoured, but I believe the behaviour differing between non-XR and XR is a bug (or at least not intuitive).

Reproduction steps

  1. Disable autoClear
  2. Render a frame with more than one render() call (e.g. clear(), render(object1), render(object2))
  3. Start an XR session and see only the result of the last render() call

Code

renderer.autoClear = false;

renderer.clear();
renderer.render(object1, camera);
renderer.render(object2, camera);

Live example

Example: https://jsfiddle.net/br1nygdk/2/

The example shows two spheres; one cyan and one magenta. When clicking 'Enter VR' only the magenta sphere is visible, whereas both should be visible. Setting autoClearColor to false works around the issue.

(Note: it's not possible to enter VR in the fiddle on a Quest, but the immersive-web-emulator can be used as well)

Screenshots

No response

Version

r152

Device

Headset

Browser

Chrome

OS

Android

@marwie
Copy link
Contributor

marwie commented Jun 26, 2023

Just came across this here as well and came to the same workaround/conclusion, setting autoClearColor to false now as well

@Mugen87 Mugen87 added this to the r155 milestone Jul 13, 2023
@mrdoob mrdoob modified the milestones: r155, r156 Jul 27, 2023
@Mugen87 Mugen87 closed this as completed Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants