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
):
BP_PlanetaryOcean
(comes from SphereMeshComponent
):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 theOriginShiftDistanceCm
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.
Because the Gerstner wave system is not tileable, each origin shift causes the entire wave system to visually shift as well. It takes one frame to shift the waves. Chances you will see this artifact are slim to none for the following reasons:
If you keep
OriginShiftDistanceCm
high (around 10,000,000 units, or 100 km), you will need to move really far to see it happening.You will have to move relatively slowly to notice this artifact.
You will have to be really close to the ocean surface, as the material fades off wave normals by distance. Even if you disable this fade-off, you still won't be able to see the artifact from a certain distance, since waves look like aliasing noise from far away.
Generally speaking, keep the OriginShiftDistanceCm
value around the default (10,000,000). If you want to disable origin shifting completely, set OriginShiftDistanceCm
to a very large number. For instance, a planet with a radius of ~10,000,000 doesn't suffer from floating-point issues at all. If you have several planets like this, you will still need origin shifting.
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?