VR screen space effects different behaviour on emulator and real VR Devices

I have to say that I think that I made this kind of test some time ago and it worked properly so maybe something has changed in a recent update.

The expectation is to have a black dot per eye and it works like that in the emulator, but if you test it on a Quest3 or Vision Pro (I have it just for some days) it will fail and more dots per eye will appear.

This is driving me nuts!

As I suspected it seems that something has changed, using Firefox and Quest3 is working ok but it fails with Meta Browser so probably it has something to do with an update.

It seems that it is no longer updating the canvas size!

https://www.babylonjs-playground.com/#92IVFV#7 << tested with canvas.width and engine._renderingCanvas.width in case of renderingCanvas != canvas.

Any other alternative to get the viewport resolution?

WebXR (when in a real XR session) does not use the canvas size. it has its own dimensions. Are you saying it used to work and now doesn’t?

That’s it, also it continues working on Firefox.

firefox in XR? or the emulator?

In Quest3 XR, in the emulator, it works on Chrome too.

i am truly confused. I thought it wasn’t working on the quest 3?

Anyhow - if you want the rendering width, take the engine’s parameter, not directly from the canvas - Test VR ScreenSpace | Babylon.js Playground (babylonjs-playground.com)

I am pretty sure it is not what you expect it to be, but this will render two black dots, one in each eye

Thank you @RaananW engine.getRenderWidth() did the work (I just have to skip the wMult value).

I tried to explain that my solution worked ok on Quest3 + Firefox but it failed with Quest3 + Meta Browser, also in the past it used to work with Quest3 + Meta Browser.

1 Like

firefox on the quest 3? You mean firefox reality? Wow, i didn’t know they still offer it. AFAIK it hasn’t been updated in ages.

Yes it was discontinued (or at least I think so) but it give me the tip that something has been changed in the Meta Browser.

the quest browser works as expected. The canvas’ width and height are not related to the XR rendering height and width. The engine is updated with the new dimensions when entering (and exiting) XR.

That’s weird but engine.getRenderWidth() works only the second time I enter into VR mode in Apple Vision Pro.

Notice that I’m using it like

const invScreenSize = new BABYLON.Vector2(
   2.0 / engine.getRenderWidth(),
   1.0 / engine.getRenderHeight()
currShader.setVector2("invScreenSize", invScreenSize);
currShader.setVector3("refPos", scene.activeCamera.position);
currShader.setTexture("textureSampler", layamaXR.textureBackground);

Are you sure this code is executed after entering xr and after the session had correctly initialized?

Yes, because it gets triggered when you make a gesture in XR, I can print the values into a UI label so I did it and it says that the engine.getRenderWidth() and engine.getRenderHeight() are 256x256 and obviously that’s madness. Exiting and entering again into XR prints 3800 or whatever the actual resolution.

If I call engine.resize() on IN_XR callback it prints 2048x1782

Thank you for your time as always!

might be the first frame initializing? I can’t reproduce this in the emulator. I always get 2732:2048.
The thing is - this is the frame buffer rendering width and height (unless you are using layers, which you probably aren’t since they are not supported in the vision PRO AFAIK). which means that if the image you are seeing has a higher resolution than 256x256, this number is incorrect. If you can output this on scene before render, check if there is one output of 256 and then right after a correction. it might be the way apple are dealing with XR init.