New: Large World Rendering! (experimental)

Large World Rendering

Hey all! We’re introducing LargeWorldRendering for 9.0 to prevent jittering caused by floating point imprecision when dealing with large coordinate systems calculations.

Note that the feature is still experimental / in development (there are some known limitations today, such as shadow rendering and billboard/infinite distance modes) however we can use this thread to consolidate asks/observations related to floating origin / large worlds :slight_smile:

You can see usage in this playground which enables swapping between scenes and testing combinations of the below engine/scene creation options. Left is without largeWorldRendering, right is with. And if you move camera you will see the jittering is gone :slight_smile:

For complete large-world rendering support across all scenes:

create engine with { useLargeWorldRendering: true }. This will internally

  1. Set engine to useHighPrecisionMatrix – which uses 64bit matrix computations instead of 32bit default, ensureing we don’t lose accuracy in the CPU-side math when calculating matrices on large world coordinates
  2. Set all scenes to useFloatingOrigin – which offsets matrix uniforms (plus some position-related uniforms/attributes) before passing to shaders – centering the camera at world origin and displacing all other scene nodes by camera’s world position. This ensures accuracy in the GPU math, as the scale of values sent to shader are smaller and can be handled with 32 bit floats.

For scene-specific large-world rendering:

create the scene with { useFloatingOrigin: true } and create engine with { useHighPrecisionMatrix: true }

  • Doing this reduces perf impact on smaller coordinate-based scenes (because we can avoid offset matrix calculations)
  • (highPrecisionMatrix is an engine-level setting that cannot differ per-scene)

Some notes

P.s: Note that because the floatingOriginOffset is applied right before sending values to shaders, the offset is not detectable from any public matrices / position getters (which was a guiding philosophy as I implemented) :slight_smile: This ensures all logic within Babylon or written by users can remain unchanged regardless of mode.

P.s.s: Also note that the usage of this feature has changed in Pull Request #17334 · BabylonJS/Babylon.js, previously it was only a scene-level creation option called ‘floatingOriginMode’).

I will add robust documentation once the feature is no longer experimental / the API is confirmed!

——————————

CCing some folks who have posted about floating origin in the past!
@3D_Wave_Design Origin Shifting (dealing with floating point precision)
@Peipol Floating Origin Physics - Questions - Babylon.js
@Petros_Pap Zoom and scaling issue, mesh flickers on movement - Questions - Babylon.js
@CrashMaster Floating origin breaks rendering when camera has a parent - Bugs - Babylon.js
@Luck_Good @imerso Why doesn’t babylonjs use (Rendering Relative to Eye) to solve the loss of precision? - Questions - Babylon.js
@Stanikkje Big and small objects - Questions - Babylon.js
@qbrunner How to fix model glitching when far away from origin - Questions - Babylon.js
@Pryme8 @samuelgirardin @imerso Floating Origin Template for BJS 5.x - Demos and projects - Babylon.js
@plopidou Why is this happening? Mesh wobble when getting close - Questions - Babylon.js
@jetibest How to do high precision transformations? - Questions - Babylon.js
@cosmochristo When I am panning the camera the model loss the precision, how can I increase the precision? - Questions - Babylon.js
@Arash_Bagheri I want to show a simple cube at the position (6738120, 1384, -4123270), But there are some distortion, what is the problem? - Questions - Babylon.js

@lucas-divinestar Rendering at 100k+ Meters Many Issues - Questions - Babylon.js
@Romain Large coordinates - Questions - Babylon.js

20 Likes

Ah, large coordinates. That’s great but the title reminds me rendering large amount of meshes/faces/bones/animations.

2 Likes

Thx @georgie, I will give a try on this old demo :

Maybe this can fix my precision detail at large zoom (street detail) out of the box.

1 Like

I am really excited for this feature :partying_face: This is so much cleaner than rebasing the origin every 10km, I am going to use it everywhere in Cosmos Journeyer!

1 Like

Does it mean the beginning of babylonjs supporting GIS, similar to Cesium

Even if we have the ‘floating point problem’ solution and want to use for GIS, there is still consideration on normalising the geometry (usually for streaming) before it hits the engine. Cesium has its own powerful API to transform this data before it hits a rendering engine. So the answer is yes and no :slight_smile:

I would still run a Cesium server and/or use their APIs if developing a BJS GIS solution.

BJS won’t become a replacement for GIS solutions. There is a very relevant tech cross-over so plugins and simple GIS solutions are definitely plausible. Cesium have documented BJS examples.

that is fair feedback! As the feature is still experimental I can change the name of the flag if it is confusing to many people. Perhaps ‘useEyeRelativeRendering’ instead of ‘useFloatingOrigin’ and ‘useLargeCoordinateRendering’? :slight_smile:

1 Like

@dalidaliW @j-te correct, a combination of Cesium and Babylon will still be your best bet. We are in close contact with the Cesium folks :slight_smile:

Also note we are planning on introducing a lightweight 3d tile viewer for 9.0, in addition to a geospatial camera. Stay tuned!

2 Likes

For ordinary people, supporting xyz blocks, geojson, Coordinate conversion is sufficient to meet most needs, and 3dtiles can already be loaded into babylonjs through third-party tools. It would be even better if it were officially launched by babylonjs

This is absolutely great news! A normalised, native solution for this in the engine is fantastic.

Adlumens will for sure make heavy and constant use of it :slight_smile:

Question: do billboards work under this mode?

1 Like

Awesome, will this play nicely with physics?

1 Like

Hello,

I tried to test on my project by adding useLargeWorldRendering: true in the engine initialization.
I don’t know if it’s normal or what, but something is wrong with the ground.
My terrain has decreased in size as if it had been rescaled.
All my objects on the field have not moved their place, but since the field is smaller and lower in Y, no object placed it properly anymore.

Here is a picture to see the difference:

useLargeWorldRendering defined false

useLargeWorldRendering defined true

Is this normal or is there something I didn’t understand?

I also tried on scene: useFloatingOrigin: true But the result is the same.