Large skybox disappears

I have setup a skybox with size: 10000.0 but the scene I am creating a is very large, if I set skybox to 30000.0 it doesn’t show skybox, and if I keep on 10000.0, my scene is not displaying full, what should I do in this situation?

            // Skybox
            var skybox = BABYLON.Mesh.CreateBox("skyBox", 10000.0, scene);
            var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
            skyboxMaterial.backFaceCulling = false;
            skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("./assets/skybox6/", scene);
            skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
            skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
            skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
            skyboxMaterial.disableLighting = true;
            skybox.material = skyboxMaterial;
            skybox.infiniteDistance = true;
            skybox.renderingGroupId = 0;

statistics from scene

here is a PG of the issue: Babylon.js Playground

I also realised its not skybox issue, if I remove skybox it is still not showing all objects in the scene, it loads part of objects on moving forward.

Hi. Increase camera.maxZ
Yourcamera.maxZ = 30000 or whatever you want
And… maybe read docs? Camera - Babylon.js Documentation

1 Like

Thanks, regarding docs, trust me I only post when I couldn’t find anything after searching everywhere, sometimes we can miss a small details, and being not very good in English is another issue. anyway thanks for the tip.

hey its only humor)) but read docs))

2 Likes

Hi,
I actually would like to reopen this issue.
I am facing a similar situation. My camera has a rather low maxZ to avoid rendering of too many objects. My skymaterial settings are similar to Dshah_H and the skybox has a size that it is a bit bigger than the rest of the scene.
Now moving around on the scene, parts of the skybox are only visible, if they are within the maxZ of the camera. I am using infiniteDistance (ping @Deltakosh ), I would have expected that the skybox still is visible no matter how large the maxZ of the camera is. What exactly is the effect of infiniteDistance?
My current workaround is to move a spheric sky"box" with the position of the camera, so it is always within bounds of maxZ.

Just realising, that inspector only shows infiniteDistance for box objects, is this correct?
It is not shown in my current spheric skybox. I just created a reflectionprobe of my skybox (since i am using the sky shader) and applied this reflectionprobe to scene.createDefaultSkybox. It created an hdrSkyBox that has a toggle for infiniteDistance. (The resulting hdrSkyBox is no looking good, though. Seems to be difficult to get a reflection texture for the sky shader. I might just use an environment map)

Weird that I find out about just after asking for help here. But I would still be curious if infiniteDistance is only available for Box Meshes, it would be great to use it on a sphere, too, since camera maxZ is spheric.

infiniteDistance is a property of TransformNode but is only used for meshes to remove the meshes with infiniteDistance = true from the computation of the world extends in Scene.getWorldExtends. So it won’t help in your case.

Why not having the skybox move with the camera even with a skybox:

https://www.babylonjs-playground.com/#S8NQ4N#1

3 Likes

Oh this is actually also very useful information! Great way to exclude the skybox from world extends calculation. Smart!

You wrote

scene.onBeforeRenderObservable.add(() => {
            skybox.position.copyFrom(camera.position);
      });

For me it also works to just asign the activeCamera position, it does not require the onBeforeRenderObservable. Are there some side effects or is this ok too?
skybox.position = scene.activeCamera.position;

No, I think it’s fine!