Streaming
Streaming keeps a large world affordable by loading what is near the camera and dropping what is not. Renzora has five mechanisms, each for a different kind of content, and they share one gate and one camera:
| Mechanism | Unit | Driven by | Code |
|---|---|---|---|
| Asynchronous scene loads | A whole scene | A game's scene load | renzora_engine::scene_stream |
| Streamed scene instances | A nested .bsn | Distance to the instance | scene_stream::drive_streamed_scene_instances |
| World partition | Grid cells of one scene | Ground distance to each cell | renzora_engine::world_partition, renzora_scene::world_partition |
| Texture tiers | A .rmip texture | Distance to the meshes using it | renzora_engine::texture_stream |
| Terrain chunks | A terrain chunk | Ground distance to the chunk | renzora_terrain::streaming |
Mesh LODs, which swap detail rather than residency, are covered at the end. There are no project.toml keys for any of this; everything is set on components and resources.
The gate and the camera
renzora_platform_api::world_streaming_active(world) decides whether distance-driven streaming runs at all:
- in a shipped game: yes;
- in the editor: only in Play, Paused or Simulate, never while editing, so the whole world stays resident and editable;
- on a dedicated server: no, because a server has no camera and must keep everything.
streaming_camera_pos(world) picks the point distances are measured from: the active scene camera marked DefaultCamera, otherwise any active scene camera, otherwise the editor camera. With no camera it returns None and residency is left alone rather than unloading everything.
World partition cells and terrain chunks have their own editor drivers (below) that measure from the viewport camera while editing.
Asynchronous scene loads
A scene load requested by a game (a script, a load group, PendingSceneLoad) despawns the current scene and then streams the new one:
- Reading and parsing run on the async compute pool: the
.rpakarchive first, then disk, then the BSN parse and the same pruning a synchronous load does. - Every entity is allocated empty, then components are written parents first, 3 ms of wall-clock time per frame, a budget shared by every stream in flight. A big level therefore arrives over several frames instead of one long stall.
SceneLoadState.progressmoves from 0 to 0.1 when parsed, then with the spawn cursor to 1.0.SceneLoaded,SceneLoadFailedandSceneLoadedWithSkippedTypesfire for the main stream when it finishes.
Only one main stream exists; starting another cancels it. Instance streams run alongside. Entities that arrive by streaming carry StreamedContent (not saved) before any of their components do.
The editor and the boot load use the synchronous scene_io::load_scene instead, so they jump from 0 to 1.
Streamed scene instances
A SceneInstance (a nested scene or prefab) loads its contents on load by default. Set streamed to load them by distance:
| Field | Default | Meaning |
|---|---|---|
source | The .bsn it instances | |
streamed | false | Load by distance instead of always |
load_radius | 150 | Contents stream in inside this distance |
unload_radius | 200 | Contents are dropped beyond this distance |
The effective unload radius is at least load_radius + 10, so an instance on the boundary does not load and unload every frame. Distance is 3D, to the instance root. Unloading despawns the children and keeps the root; a stream still in flight for it is cancelled. Leaving Play re-expands everything, so the editor shows the whole world again. In edit mode streamed instances are simply expanded.
World partition
A WorldPartition component in a scene divides it into a grid of cells (if there are several, the first found applies). Each cell is a separate file, scenes/<scene>.cells/<x>_<z>.bsn, instanced by an entity carrying PartitionCell { x, z, has_hlod }. In a game, each cell streams like any other SceneInstance, with the partition's radii copied onto it.
WorldPartition field | Default | Meaning |
|---|---|---|
cell_size | 1000 | Cell edge length |
load_radius | 1500 | Cells load inside this ground (XZ) distance |
unload_radius | 2000 | Cells unload beyond it; at least load_radius + cell_size / 4 |
stream_in_editor | true | Stream cells around the viewport camera while editing |
editor_load_all | false | Load every cell in the editor |
Partitioning. Partition into cells on the Hierarchy's context menu moves the selected scene's models into cell files, assigning each by the centre of its bounds as read from the model file.
In the editor. Cells near the viewport camera are loaded, nearest first, at most four at a time, with a Loading world cells card in the viewport. A cell can be pinned (PartitionCellPinned) to keep it loaded. A cell with unsaved changes is written back to its file before it unloads.
Revealing cells. A freshly streamed cell stays hidden until its models, materials and textures have loaded, checked every 0.2 s, and is shown after 20 s regardless. While any cell is waiting, the GPU upload budget per frame is raised to 48 MiB so the wait is short. Without this a cell would pop in untextured and then pop again.
Distant stand-ins (HLOD). Build distant LODs in the editor (desktop only) bakes a stand-in model for each cell, <x>_<z>.hlod.glb. At run time the stand-in is shown whenever the cell's full contents are not, so the horizon is never empty. A cell that leaves view with no stand-in produces a Console warning.
Texture tiers
Every .rmip texture carries a low-resolution tier, the tail of its mip chain with the largest side at most 256 pixels, available as the #low labelled sub-asset. texture_stream swaps materials between the full and low tiers by distance:
TextureStreamingSettings field | Default | Meaning |
|---|---|---|
enabled | true | |
full_distance | 60 | Full resolution inside this distance |
low_distance | 90 | Low resolution beyond this; at least full_distance + 5 |
- It runs twice a second, only while
world_streaming_active, and not on a dedicated server. Leaving streaming restores every texture to full. - Distance is from the streaming camera to the nearest entity using the material. A material with no mesh using it is left alone.
- Only
StandardMaterialslots are tiered (base colour, normal, metallic-roughness, occlusion, emissive), and only images loaded from.rmip. Graph materials and terrain textures are not. - A swap happens in two phases: the decision starts loading the target tier, and the material is switched only when every target image has arrived, all slots at once. A material is never shown with a mix of tiers or a missing texture.
A block-compressed full tier keeps no CPU copy, and the low tier never does, so a texture's memory is mostly on the GPU.
Terrain chunks
TerrainData streams its chunks when stream_chunks is on (the default for a new terrain; a terrain saved before the option existed loads with it off):
- Chunks within
stream_radius(default 512, at least one chunk size) of the camera, measured on the ground, are resident. A chunk is streamed out one chunk size farther away, so a chunk on the edge does not churn. - A streamed-out chunk loses its mesh and physics and is marked
TerrainChunkStreamedOut. A coarse stand-in mesh (StreamProxy, about 8 cells across, with full-detail edges so it meets its neighbours without cracks) is drawn in its place. - Chunks are rebuilt at most 12 per frame, nearest first; a progress card appears when more than 24 are waiting.
- The editor camera is used while editing. A dedicated server keeps every chunk.
Mesh LODs
MeshLod on a model entity swaps between pre-built detail levels using Bevy's VisibilityRange:
| Field | Default | Meaning |
|---|---|---|
enabled | true | |
distances | [40, 100, 220] | Where each coarser level takes over; extra levels continue at ×2.2 |
crossfade | 5 | Distance over which neighbouring levels blend |
cull_distance | 0 | Hide entirely beyond this; 0 never culls |
Levels are files beside a .glb model named <stem>_lod1.glb up to <stem>_lod4.glb, found in the archive or the project folder, stopping at the first missing one. They can be generated at export (Generate mesh LODs, off by default, 3 levels, each halving the triangle count). Only .glb models use this: an .rvg model's detail comes from its virtual geometry clusters instead.
Unlike the rest of this page, mesh LODs are not gated by world_streaming_active: Bevy evaluates VisibilityRange per view, so they work in the editor viewport as well.
The Streaming panel
The editor's Streaming panel shows every mechanism working: the gate and the camera, scene streams in flight, streamed instances with their distances and state, terrain chunk residency, mesh LOD bands and texture tier changes. It refreshes four times a second while it is the active tab and costs nothing when hidden.