Max skybox size in WebXR

Is there a hidden limitation to the maximum size of a skybox using a cubemap in BabylonJS? I ran a few experiments, and for desktop I could easily do 10,000 unit sizes, while WebXR was restricted to 1000. Skybox set to ‘infinite distance’.

The texture size itself is limited by the WebGL stack could be from 2048 to 16777216 depending on the hardware.

The box size itself will depend mostly on the camera.farz setup and as WebXR is providing us with the Matrix I guess they might limit it to 1000 which would fit with 1km in real life. not sure we can change it @RaananW ?

Hi @Pete_Markiewicz,

great question!

The catch with WebXR is that changing the maxZ of the camera is not enough. You also need to update the render state with the new depthNear and depthFar parameters.

During the enterXR function, the following code is executed (async):

    baseLayer: renderTarget.xrLayer!,

As you can see, it takes the maxZ of the XR camera and uses it (which is 1000 per default), but it doesn’t let you update the maxZ after setting it, or setting it in the options.
After initializing the XR experience, you have access to the camera. if you update those values prior to entering XR (before the user presses the GUI button, which is technically any time after the init was done) they will be used when entering XR.

Yes, that does work! However, I found that going to a really large skybox chokes my setup - in fact, manages to crash the browser. So for now, I’m just shrinking the skybox when entering XR. For a 3D star simulation using the Hyg3 database, you have to leave out the more distant stars. If you set units to 10x parsec distances, you can get the stars in a few hundred light years inside the skybox, about 1/2 of the total (119k). Solution moving the skybox with the camera?

Moving the skybox along with the camera (position only, so no parenting) will probably be the simplest and most efficient solution. I understand the need to create a realistic skybox especially size-wise), but for rendering it makes no difference how big the skybox is, and you should do whatever you can to make the scene render as fast as possible.