# WebXR layers feature broken on Quest 2 with skybox and environment

**URL:** https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258
**Category:** Bugs
**Created:** [January 31, 2022, 6:07pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258 "2022-01-31T18:07:50Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [January 31, 2022, 6:07pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/1 "2022-01-31T18:07:50Z")

</div>

Hi,  
Recently I tried to enable the new WebXr layers feature so that the Quest 2 renders both eyes in a single pass.  
It is most definitely a performance improvement, however I did see 2 issues when enabling this feature with a skybox and environment:

1. Controllers seem oversized
2. pbr reflections are stretched to a single point

A playground to show these issues is here:

> **[Babylon.js Playground](https://playground.babylonjs.com/#9K3MRA%23741)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Thanks

---

<div class="post-metadata">

### Author: ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)
#### Post date: [January 31, 2022, 6:47pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/2 "2022-01-31T18:47:34Z")

</div>

cc @RaananW

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [February 1, 2022, 11:04am UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/3 "2022-02-01T11:04:12Z")

</div>

thanks for letting us know! We’ll look into it

---

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [February 28, 2022, 6:01pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/4 "2022-02-28T18:01:39Z")

</div>

Hello @RaananW,  
Since pull request [[XR] Fix updateTransformMatrix for multiview by rgerd · Pull Request #11934 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/11934) was merged, this immediate issue looks much better. Really appreciate the fix 😃

I have found some other related issues that occur when enabling multiview:

1. Anti-aliasing is disabled on Quest 2. This can be seen by comparing the following playgrounds:
  - Multiview off: [https://playground.babylonjs.com/#9K3MRA#788](https://playground.babylonjs.com/#9K3MRA#788)
  - Multiview on: [https://playground.babylonjs.com/#9K3MRA#741](https://playground.babylonjs.com/#9K3MRA#741)

2. When exiting XR on the Quest 2 using the playground with Multiview enabled ([https://playground.babylonjs.com/#9K3MRA#741](https://playground.babylonjs.com/#9K3MRA#741)) the view rendered in the 2d Oculus browser has reflections that are broken in the same way as they used to be in XR (my original post)
3. scene.clearColor is ignored and the scene is always cleared with a black colour, as seen in this playground: [https://playground.babylonjs.com/#9K3MRA#789](https://playground.babylonjs.com/#9K3MRA#789)

Hope the above is clear, thanks again

---

<div class="post-metadata">

### Author: ![kaliatech](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kaliatech/32/13557_2.png) [@kaliatech](https://forum.babylonjs.com/u/kaliatech)
#### Post date: [February 28, 2022, 7:16pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/5 "2022-02-28T19:16:42Z")

</div>

I’m also experimenting with WebXR layers (and multiview). Regarding the anti-aliasing issue, I came across this information if it helps:

- Ongoing thread that is relevant (I think)

- Relevant example on immersive-web (using `OCULUS_multiview` extension)

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [February 28, 2022, 7:23pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/6 "2022-02-28T19:23:58Z")

</div>

Thanks for reporting!  
Apart from the antialiasing (which is a known issue with multiview in general, solved by the OCULUS muttiview extension), the other 2 are bugs. Do you mind opening a github issue to track them? ping me there, i’ll make sure to tag and assign it.

---

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [February 28, 2022, 10:32pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/7 "2022-02-28T22:32:50Z")

</div>

Hi @RaananW,  
Thanks for getting back to me, I’ll create the 2 bugs first tomorrow 👍

However I do believe there is an issue with the implementation of the OCULUS muttiview extension as I am testing on A Quest 2 and see aliasing.

After reading through the code I see that the method bindMultiviewFramebuffer of file engine.multiview.ts calls framebufferTextureMultisampleMultiviewOVR, once with the colour and once with the stencil. For both of these calls multiviewTexture.samples is passed in as the samples parameter, however this value is 0. My understanding is that it would need to be a value of 2, 3 or 4 for anti-aliasing to work.

As a quick test in my own project I set the Engine.prototype.bindMultiviewFramebuffer myself and hardcoded the samples to be 4 and anti-aliasing started working on My Quest 2. I did have some weird issues, that may be related to rendering layers (layer 0 wasn’t rendered until I added another item to my scene) but it was a quick test as it is quite late where I am right now.

I shall revisit it tomorrow, but I would appreciate your thoughts on this.

Thanks

---

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [March 1, 2022, 10:24am UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/8 "2022-03-01T10:24:39Z")

</div>

Hi @RaananW,  
The 2 bugs have been created as requested:

- [2d rendering is broken after exiting XR mode](https://github.com/BabylonJS/Babylon.js/issues/12067)
- [scene.clearColor is ignored within XR mode](https://github.com/BabylonJS/Babylon.js/issues/12068)

I also looked further into the aliasing issue on the Quest 2. Here is a playground where I force the samples parameter to be 4 when calling into framebufferTextureMultisampleMultiviewOVR: [https://playground.babylonjs.com/#9K3MRA#794](https://playground.babylonjs.com/#9K3MRA#794)

Note that nothing on renderingGroupId=0 actually renders, so all items except the skybox are moved to renderingGroupId=1, which ensures they are rendered.  
All of the rendered items are correctly anti-aliased on the Quest 2. Am I missing something in the configuration which enables anti-aliasing correctly on the Quest 2 when multi-view is enabled? Or is this an example of a real issue, and that samples should in fact be set to the value held within the Engine.getCaps().maxSamples ?

If I am correct about the samples, then why would rendering group 0 be ignored? (maybe it is cleared after being rendered?)

Really interested to hear your thoughts.  
Thanks.

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [March 1, 2022, 11:12am UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/9 "2022-03-01T11:12:07Z")

</div>

That’s an interesting catch. The number of samples is set on the class MultiviewRenderTarget, which is the RTT used when enabling multiview. When initializing it, is uses `this.samples = this._getEngine()!.getCaps().maxSamples || this.samples;` to set the number of samples (defaults to 1). So it should work as expected! keyword is “should”. I’ll have to debug this and see what’s going on there. Let me assign myself and get back to you on this one. I am sadly a bit swamped at the moment, but I promise to take the time to check that.

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [March 1, 2022, 11:12am UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/10 "2022-03-01T11:12:11Z")

</div>



---

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [March 21, 2022, 10:51am UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/11 "2022-03-21T10:51:52Z")

</div>

Hi @RaananW,  
I was just wondering if you have had chance to look into the samples issues when using the Oculus Multiview extension? It seems that the number of samples is still not being set correctly to me.

I can confirm that when I over-ride the Engine.bindMultiviewFramebuffer method to force the number of samples to 4,I no longer get issues with layers: [https://playground.babylonjs.com/#9K3MRA#808](https://playground.babylonjs.com/#9K3MRA#808)

However, by default anti-aliasing is not working on the Quest2 as seen here: [https://playground.babylonjs.com/#9K3MRA#741](https://playground.babylonjs.com/#9K3MRA#741)

I realise you are all crazy busy and we all appreciate the work you all do.  
Thanks.

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [March 23, 2022, 6:55pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/12 "2022-03-23T18:55:39Z")

</div>

> [@Charge](#):
>
> I was just wondering if you have had chance to look into the samples issues when using the Oculus Multiview extension

Sorry, no I didn’t… But I promise to find time this week. It should actually be a very straightforward fix.

> [@Charge](#):
>
> I realise you are all crazy busy and we all appreciate the work you all do.  
> Thanks.

Very much appreciated! 🙂

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [April 5, 2022, 2:33pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/13 "2022-04-05T14:33:29Z")

</div>

Took way longer than it should have, sorry again

This PR solves it - [[XR] assign the number of textures correctly by RaananW · Pull Request #12340 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/12340) . Working wonderfully in the oculus browser.

After it is merged it will be in the next version released (either 5.0.4 or 5.1.0, depending on the release schedule).

---

<div class="post-metadata">

### Author: ![Charge](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charge](https://forum.babylonjs.com/u/Charge)
#### Post date: [April 5, 2022, 2:44pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/14 "2022-04-05T14:44:45Z")

</div>

Thanks @RaananW 👍

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [April 5, 2022, 3:01pm UTC](https://forum.babylonjs.com/t/webxr-layers-feature-broken-on-quest-2-with-skybox-and-environment/27258/15 "2022-04-05T15:01:27Z")

</div>


