Scalability and Precision

Planetary Oceans is designed to simulate ocean surfaces on both small planetary bodies and massive planets, with support (with some caveats described below) for oceans exceeding 10,000,000,000 Unreal Units (100,000 km) in radius.

Mesh Generation (CPU)

Vertex position calculations are performed using 64-bit doubles. After the mesh data is finalized, both the mesh origin and vertex positions are rebased to the camera location to avoid floating-point imprecision during rendering. The vertex data is then converted to 32-bit floats and passed to the engine for rendering, as the engine expects all vertex data to be represented in floats.

Parameters in BP_PlanetaryOcean (comes from SphereMeshComponent):

Parameter
Description

GeometryUpdateDistanceCm

Distance in centimeters camera (both editor and in-game camera) must be traveled before the ocean geometry is regenerated to keep dense geometry near the observer. This does not shift the origin.

OriginShiftDistanceCm

Distance in centimeters the camera must move before the mesh origin is rebased (shifted) to the current camera location. This helps prevent precision loss in large-radius scenarios.

How and When the Mesh Origin Is Rebased

  • Once the level is loaded, the mesh origin is initially placed at the editor camera location.

  • Once the game starts, the mesh origin is placed at the in-game camera location (e.g., the camera component of your character).

  • Both before and after BeginPlay, the mesh origin is rebased every time the camera travels a distance greater than the value specified by the OriginShiftDistanceCm parameter. The distance is measured from the most recent mesh origin location.

Waves generation (GPU)

The ocean material tries to avoid absolute world space as much as possible. It also takes into account the mesh origin and calculates vertex positions relative to it.

Buoyancy (CPU)

The buoyancy system takes the mesh origin into account and adapts to wave positions when the origin is rebased. All material calculations related to avoiding floating point imprecision are mirrored in the buoyancy component (check UOceanFunctionLibrary::WorldToPeriodicWorldSpace).

Last updated

Was this helpful?