ShaderMaterial with WebXR

Hi everyone,
I’m new there and have some questions about WebXR.
I just finished to migrated an old massive project from BabylonJs 2.4 to Babylon 5.27.
Everything seems to working well but there is a lot of customisation like shaderMaterial, our camera extended the Babylon.Freecamera but have a lot a method and options.
I try to activate the WebXR inside the project but I always got the same warning :

 var xr = await scene.createDefaultXRExperienceAsync();

error :=>
 Session mode "immersive-vr" not supported in browser

And the VR ui does not appears. Everythink is working well in WebXR playground exemple in my navigator and WebXR emulator.

If I use the deprecated WebVR, I have the VR UI and if I clic on it the dual screen is displayed (but the WebXR device emulator does not move the camera).

  • I’m pretty sure that the costumisation are the reason of my problem, does the shaderMaterial are compatible with WebXr?
  • Does I have to #include some code in my shaderMaterial?
  • Could I extend the Babylon.freecamera without problems to activate WebXR ( I can see that the class of my camera change when WebVR is activated) ?
    Thanks a lot for any help.


I will answer about WebXR - to use WebXR you need a browser that supports webxr and the session you are asking (in your case a vr immersive session). WebXR doesn’t do split screen, but if you do want split screen you can use the webxr emulator. You need to be sure the emulator is enabled before running the scene, and that it is running in a browser that supports webxr. The error code you pasted indicates that either the browser doesn’t support webxr altogether, or that there is no emulator or device connected to it that will render the XR session.

Thanks for your time, as I try to explain, my browser is working very well with WebXR and WebXR emulator on all the WebXR demo I tested (in the PG and elsewhere). That does not seem to be the problem…

sorry, just for me to fully understand - webxr in the playground works well, but doesnt work in your project?


can you share the project? It is weird that the error is a webxr error and not some exception thrown.

I cannot share the project unfortunately, I will try to send you the tile stack if it can help, when the WebXR test is done.

Then a reproduction would be great. If the playground works but the project doesn’t there is something wrong in the project itself, since it’s the same framework running. I assume you use the latest 5.X?

Hello @Nico_BnX just checking in if you can share a reproduction, it doesn’t need to be your entire project, just something that demonstrates the problem, the simpler the better