Atmosphere: floating origin mode assumes the world origin is the planet centre (black sky in ground-level scenes)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- computer-graphics, game-dev
Research direction
Read AtmospherePerCameraVariables.update and AtmospherePBRMaterialPlugin.bindForSubMesh in the atmosphere addon; the issue identifies both floating origin calculations that assume the origin is the planet centre. Trace how planet radius and origin offsets are used, then compare a ground level scene with floating origin enabled against the same scene without it. Done when the sky and PBR lighting match in both modes while existing globe behavior remains intact.
Written by the indexing model from the issue text.
Description
Summary
With useLargeWorldRendering: true (so scene.floatingOriginMode is on), Atmosphere from @babylonjs/addons assumes that the world origin is the planet centre. A ground-level scene, where the origin is on the surface (the usual case outside geospatial globes), then gets a black sky, and PBR materials that receive the atmosphere plugin are lit with a wrong offset. Without useLargeWorldRendering the same scene renders a correct sky.
Version: @babylonjs/core and @babylonjs/addons 9.37.1, Chrome 158, WebGL2 (ANGLE Vulkan) and WebGPU.
Where
AtmospherePerCameraVariables.update: in floating origin mode it normalizes the camera's global position as the geocentric normal and addsoriginHeightalong it. With the origin on the ground the camera is ~0 km from the "planet centre", so it is clamped onto the surface with an arbitrary "up". The non-floating branch (y += planetRadius + originHeight) is what a ground-level scene needs.AtmospherePBRMaterialPlugin.bindForSubMesh: in floating origin modeoriginOffsetKmisfloatingOriginOffset * 0.001only, without the planet radius that the non-floating branch adds, so world positions are treated as planet-centred too.
Repro
Any scene with a camera a few metres above y = 0 and a DirectionalLight pointing down:
const engine = new BABYLON.Engine(canvas, true, { useLargeWorldRendering: true });
// scene, camera at (0, 1.7, 0), sun = new DirectionalLight("sun", new Vector3(0.4, -1, 0.5), scene)
const atmosphere = new ADDONS.Atmosphere("sky", scene, [sun]);
Expected: the same blue sky as with useLargeWorldRendering: false. Actual: black sky (the sky compositor runs, but the camera is placed inside the planet).
Possible fix
An option telling the atmosphere where the planet centre is in floating origin mode (for example a boolean "origin on the surface" or an explicit planet-centre offset), used by both places above, keeping today's globe behaviour as the default. We work around it locally by running update as in the non-floating branch and by adding (0, planetRadius, 0) to originOffsetKm after bindForSubMesh; frames then match the non-floating scene.
- Dominant language
- TypeScript
- Stars
- 26.6k
- Forks
- 3.8k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 112
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BabylonJS/Babylon.js
-
WebGPU: Geometry._invalidateVertexBuffers throws 'mesh.subMeshes is not iterable' for a mesh without sub-meshesPossibly taken @vladosskins178 claimed this 14 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
BabylonJS/Babylon.js#19188 ·
Maintainers usually reply within 1 day
-
WebGPU compressed cube readback feeds encoded blocks to diffuse irradiance calculationPossibly taken @yucheng-du claimed this 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 54/100
BabylonJS/Babylon.js#19278 ·
Maintainers usually reply within 1 day
-
[WebGPU] A render effect whose WGSL fails to compile never reaches onError: isReady() is true and every draw fails on an invalid pipelinePossibly taken @Popov72 claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
BabylonJS/Babylon.js#19224 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
enhancement Gaussian Splatting native
Difficulty 4/5 3-5 days Newbie friendliness 43/100
BabylonJS/Babylon.js#19145 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
BabylonJS/Babylon.js#19131 ·
Maintainers usually reply within 1 day
All issues in BabylonJS/Babylon.js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
ardia-browser/ardia#6391 ·
Maintainers usually reply within 1 day
-
Feature:Actions/ConnectorTypes Team:ResponseOps
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
elastic/kibana#309028 · 1 comment ·
Maintainers usually reply within 1 day
-
🔨 tool 🧰 library
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Orange-OpenSource/Orange-Boosted-Bootstrap#4035 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
DISIC/teleservice-conformite#230 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
rothgar/rabble.radio#410 ·
Maintainers usually reply within 1 day