In this lesson, you will learn how to define custom grid sizes and loading ranges to control the streaming granularity of your open-world environments.
The Strategy of Spatial Grid Design
While World Partition provides the backbone for streaming, the efficiency of your memory footprint depends entirely on how you define your grid cells. A spatial loading cell is essentially a discrete box in 3D space that dictates when an actor is loaded into or evicted from memory.
If your cells are too large, you risk "bloated" memory, where a player triggers the loading of a massive block of assets even if they only need a small portion of it. Conversely, if your cells are too small, you increase the overhead of the engine's background loading system, as it must constantly track and swap hundreds of tiny actors, potentially leading to hitching.
Configuring Grid Size and Loading Range
To optimize, you must align your GridSize with the average density of your assets. You define these settings within the World Settings or the World Partition Setup dialogue.
- Grid Size: Determines the physical dimensions of the cell (e.g., 6400cm or 12800cm).
- Loading Range: Defines the distance from the player (the "Streaming Source") at which cells transition from an unloaded state to loaded.
For example, if you have a dense forest, smaller grid sizes allow you to load only the immediate canopy, while sparse desert regions can use significantly larger cells to reduce the number of objects tracked by the runtime memory manager.
Practical Implementation
You can visualize your grid settings by enabling World Partition Editor and checking the "Grid" view. To adjust the load behavior, configure the WorldPartitionRuntimeSpatialHash settings:
// Logic conceptualization for adjusting grid cell behavior
// Increasing LoadingRange allows more time for background asset streaming
// Decreasing GridSize improves granularity but increases actor count overhead
void ConfigureWorldGrid(float CellSize, float LoadingRange) {
// These values are typically set in the WorldPartition Editor,
// but the engine uses them to calculate streaming source proximity.
}
By carefully tuning these parameters, you ensure that the engine’s memory pressure remains stable even as the player moves rapidly across your world.
Key Takeaway: Balance your grid cell size against your asset density to minimize wasted memory while ensuring the streaming system has enough lead time to load assets before they come into the player's view.