Asset Pipeline
This page follows a file from the moment it enters a project to the moment a shipped game reads it: how models and textures are converted on import, the engine's own file formats (.rvg, .rmip, .rpak), how a load finds its bytes, and the load-group API games use to preload. For importing as a user, see Models; for scenes, see Scenes.
The layers
| Layer | Crate | Job | Exists in |
|---|---|---|---|
| Import | renzora_import, renzora_import_ui | Convert source models to the engine's formats; bake textures | Editor (and the companion process) |
| Registry | renzora_asset_registry | Index every project file's path, kind, size and time | Editor |
| Virtual file system | renzora_engine::vfs | Find and mount the game's .rpak archive | Game |
| Asset reader | renzora_engine::asset_reader | Serve bytes to Bevy's AssetServer: archive, then project, then beside the executable | Both |
| Loaders | per format | Turn bytes into assets (.rvg, .rmip, .svg, .anim, ...) | Both |
| Packing | renzora_rpak, renzora_export | Collect what a game uses into one archive | Export |
Code loads assets the ordinary Bevy way. Paths are project-relative:
let model: Handle<Gltf> = asset_server.load("models/house.rvg");
let hull: Handle<Scene> = asset_server.load("models/ship.rvg#Scene0");
let albedo: Handle<Image> = asset_server.load("models/textures/brick_albedo.rmip");
How a load finds its bytes
The archive
A game started without the editor looks for an archive once, at boot (Vfs::detect). The editor never mounts one.
| Platform | Looked for |
|---|---|
| Android | game.rpak in the app's files directory, then the APK's assets |
| iOS | game.rpak in the app bundle |
| Web | The bytes the page fetched (./game.rpak), handed over with set_wasm_rpak |
| Desktop | --rpak <path>, then an archive appended to the executable, then <exe stem>.rpak beside it |
With none found, the game reads loose files. A found archive is published as the Vfs resource and the SharedArchive the asset reader holds, and project.toml is read from inside it.
The asset reader
setup_asset_reader(app) installs EmbeddedAssetReader as Bevy's default asset source before DefaultPlugins. Each read tries, in order:
- An absolute path, read directly.
- The mounted archive (keys use
/). <project>/<path>, once a project is open.- On the web, the browser-side project store.
<exe dir>/<path>.<working dir>/<path>.
Bevy .meta files are never served (read_meta always answers not found), which is why per-asset options live in sidecars such as <file>.svg.toml instead. Hot reload is driven by the editor's file watcher, which forwards project changes to the asset server (see File Watching).
Scripts and other non-Bevy readers go through the same archive with Vfs::read / read_string, which try the archive first and then the file system.
The registry
AssetRegistry is an editor-only, metadata-only index: AssetEntry { path, kind, size_bytes, mtime_secs } for every file in the project, rebuilt each time a project opens (skipping dot-folders, target and node_modules). It holds no bytes and loads nothing. Accessors: get, iter, iter_kind, len.
AssetKind classifies by extension (AssetKind::from_path):
| Kind | Extensions |
|---|---|
Model | rvg, glb, gltf, obj, fbx, usd, usda, usdc, usdz, abc, dae, blend |
Texture | Everything in IMAGE_EXTENSIONS |
Material | material, material_bp |
Scene | bsn |
Audio | wav, ogg, mp3, flac, opus |
Video | mp4, avi, mov, webm |
Script | rs, plus the extensions of three common interpreted languages |
Shader | wesl, wgsl, glsl, vert, frag, hlsl |
Particle | particle |
Animation | anim |
UiTemplate | html |
Other | everything else |
The kind is a classification for browsing, not a promise that something loads the file: opus is classified as audio but no audio loader decodes it, and vfx effects are Other.
Importing models
Formats
| Extensions | Converted by |
|---|---|
glb, gltf | Already glTF; optimised directly |
fbx | ufbx (not available on the web) |
obj, stl, ply, abc, dae | Built-in converters |
usd, usda, usdc, usdz | Built-in USD converter |
blend | A local Blender install, run as a separate process (BLENDER_PATH or a standard location) to export a GLB |
bvh | Animation only: conversion always declines and the animation extractor takes over |
Plugins add formats with renzora::register_import_format(ImportFormat { name, extensions, convert }); renzora_import::supported_extensions() merges them with the built-in list. A plugin format converts in the editor process, never in the companion.
One pipeline
Every format becomes a GLB first, and the same pass then runs over every GLB, so a safeguard added once applies to every source format:
OBJ / FBX / USD / Collada / Alembic / STL / PLY / plugin format
| format-specific: geometry, materials, where each texture lives
GLB
| shared (gltf_pass::finish_converted_glb):
| spec-gloss baking, texture roles, .rmip baking, texture budget,
| material extraction, unsupported-extension stripping, structure
ImportResult
A converter owns two things beyond geometry: complete glTF materials (channels glTF cannot express, such as a separate opacity or specular map, travel in a RENZORA_materials_legacy vendor extension), and recording where each texture lives (embedded in the GLB, or an absolute path the shared pass rewrites).
Every GLB leaving the pipeline is made loadable by a core-glTF reader (glb_compat): required extensions nothing here implements are dropped, and KHR_materials_pbrSpecularGlossiness is baked down to metallic-roughness, including per-pixel glossiness repacked into a real metal-rough texture. Without that, a spec-gloss model whose data lives only in the extension loads untextured and white.
Things a converter gets right so you do not have to
- Units and axes. Output is metres, Y-up, right-handed. FBX asks
ufbxforright_handed_y_upatImportSettings::scalemetres per unit and bakes each instance'sgeometry_to_worldinto its vertices, becauseufbxputs the conversion in node transforms when a scene has many placements. Skinned meshes stay in geometry space, since their bind matrices are defined from it. USD, USDZ and Collada report their own units.UpAxis::Autofollows each format's convention, which for STL means Z-up. - Per-corner attributes. FBX stores UVs and normals per face corner. The converter emits one entry per corner and collapses identical ones with
ufbx::generate_indices, so seams and hard edges survive. - Legacy materials.
ufbxpresents every material through one PBR view, which misreads legacy shaders (a PhongTransparencyFactorof 1 means opaque but lands in transmission). The extended PBR channels are read only for real PBR shader types; Lambert, Phong and MTL materials get glTF defaults. - Instancing. A mesh used by several FBX nodes is written once per node; GLB node instancing is not preserved.
Settings
ImportSettings defaults:
| Field | Default |
|---|---|
scale | 1.0 |
up_axis | Auto (YUp, ZUp) |
structure | Preserve (FlatPerMesh, Combined) |
flip_uvs | false |
generate_normals | true |
texture_set | None |
optimize_vertex_cache, optimize_overdraw, optimize_vertex_fetch | true |
extract_skeleton, extract_animations, extract_textures, extract_materials | true |
texture_compression, texture_high_quality | true |
texture_max_size | 2048 |
Sibling texture sets. STL has nowhere to record materials, so the importer scans a textures/ folder beside it, groups files into sets by stripping role suffixes (_Base_Color, _Normal_OpenGL, _N, ...), and offers them as a choice. Nothing is bound automatically: packs often ship competing sets, and a wrong guess looks deliberate. Only geometry-only formats consult this.
What is written
Committing an import writes:
- the model as an
.rvg(built byrenzora_rvg::bake::build_model), or as a.glbif it cannot be built (no triangles) and always on the web, where virtual geometry is unavailable; - textures as
.rmipunder<model dir>/textures/; - one
.materialper material under<model dir>/materials/; - animations as
.animclips.
The import window converts into staging (<project>/.cache/import_staging/<n>/): convert, optimise (optimize_glb), extract animations, compact (compact_glb, which drops embedded image bytes and keyframes nothing references any more). Accepting applies your exclusions (prune_glb), builds the .rvg inside staging on a background task, and then moves the finished tree into the project, which is why accepting is instant. With a companion process connected, conversion and building run there as model_convert and model_build jobs.
convert_in_place, import_tree_in_place and import_tree_in_background are the programmatic entry points; the tree variants replace the source file with the converted model.
GLBs that use Draco or meshopt compression, or GPU instancing, are left byte-for-byte as they are by compaction and pruning: rewriting their buffers would break the compressed views.
.rvg: the model format
An .rvg is a model with its virtual geometry: the glTF scene, plus every mesh split into clusters of at most 128 triangles arranged in a level-of-detail graph.
- Header
RVG1, format version 4, a builder version, an FNV-1a hash of the source, and the body length; the body is one zstd frame. - Vertex arrays are byte-shuffled, normals and tangents octahedral-encoded, cluster vertices delta and zigzag coded, which is what makes zstd effective on them.
- The body ends with the model's scene as a GLB, with each covered primitive's triangles replaced by a coarse proxy, so the file is complete on its own.
RvgModelLoader loads an .rvg as a Gltf, so labels work exactly as for a .glb (#Scene0, #Mesh0/Primitive0), and the clusters are at #Clusters. Where virtual geometry rendering is off (the web), the model draws its full-detail meshes the ordinary way.
An .rvg can also sit beside a .glb of the same stem as a sidecar. renzora_rvg::bake::ensure_current rebuilds stale sidecars before an export, and the editor's converter queues one whenever a .glb is added or changed.
.rmip: the texture format
Every texture an import extracts is baked to .rmip: the full mip chain, block-compressed for the GPU, so a load is a copy rather than a decode.
- 24-byte header:
RMIP, version (2; 1 is still read), width, height, mip count, format code. Mips follow, largest first. - Formats: RGBA8 (sRGB or linear), BC7, BC5, BC1, BC3, BC4.
| Texture | Format |
|---|---|
| Compression off | RGBA8 |
| Normal map | BC5 |
| Colour, high quality | BC7 sRGB |
| Colour with alpha, standard quality | BC3 sRGB |
| Colour without alpha, standard quality | BC1 sRGB |
| Linear data | As colour, linear variants |
Baking decodes with the image crate (PNG, JPEG, WebP, BMP, GIF, TIFF), clamps the largest side to texture_max_size, and builds Lanczos3 mips, premultiplying by alpha while resizing so transparent pixels do not bleed their colour into edges, and renormalising normal maps. Block-compressed textures are resized to a multiple of 4 first, because a BC block is 4×4. Encoding uses intel_tex_2 and is desktop only.
DDS files are repacked rather than decoded: DXT1, DXT5, BC4, BC5 and DX10 blocks are copied straight into an .rmip, dropping leading mips to meet the size cap. Cubemaps, volume textures and other formats are copied unchanged.
The texture budget. The textures of one import are kept under 512 MB: the size cap is halved (never below 256) until the total fits, with a warning when it drops.
RmipAssetLoader uses Bevy's ImageLoaderSettings, so the glTF loader routes .rmip image URIs through it. Each .rmip also exposes a #low sub-asset, the tail of its mip chain no larger than 256 pixels, which texture streaming swaps in for distant materials (see Streaming). A block-compressed texture keeps no CPU-side copy.
Other file formats
Images. IMAGE_EXTENSIONS (in renzora_project_api::image_formats, also renzora::IMAGE_EXTENSIONS) is the list of everything that loads as an Image: png, jpg, jpeg, bmp, tga, webp, hdr, exr, ktx2, dds, rmip, svg, svgz. Use it, with is_image_extension and is_image_path, for a texture slot or a file picker instead of writing your own list. SVG is covered on SVG.
Loaders registered by engine crates:
| Extension | Asset |
|---|---|
rvg | Model (renzora_rvg) |
rmip | Image (renzora_rmip) |
svg, svgz | Image (renzora_svg) |
anim, animsm, skel | Animation clip, state machine, retarget skeleton (renzora_animation) |
vfx, particle | Particle effect, current and legacy (renzora_particles) |
wgsl | Shader in the pre-WESL dialect, translated on load (renzora_shader) |
tgraph | Terrain graph (renzora_terrain_graph) |
Scenes are .bsn, read by the scene pipeline rather than an asset loader. At run time, models load as .rvg, .glb or .gltf; the other model formats exist only as import sources.
Load groups
renzora::assets (renzora_asset_api) lets a game load assets ahead of need and watch progress, for loading screens and level transitions. The work is done by renzora_engine::asset_loading; requests made through the AssetLoads resource apply on the next frame.
use bevy::prelude::*;
use renzora::assets::{AssetLoads, SceneActivation};
fn start_level_two(mut loads: ResMut<AssetLoads>) {
loads.load_scene("level2", "scenes/level2.bsn", SceneActivation::Manual);
}
fn loading_screen(mut loads: ResMut<AssetLoads>) {
info!("level two: {:.0}%", loads.fraction("level2") * 100.0);
if loads.is_ready("level2") {
loads.activate("level2");
}
}
| Method | Effect |
|---|---|
create(name), append(name, &paths), start(name) | Build a group, then load it |
preload(name, &paths) | Create, append and start in one call |
pause, resume, stop, unload | Control a group |
load_scene(name, path, activation) | Load everything a scene uses; WhenReady switches to it as soon as it is loaded, Manual waits for activate(name) |
progress(name), fraction(name), is_ready(name), groups() | Read progress |
LoadProgress carries state (Idle, Loading, Paused, Stopped, Ready, Activated), counts, bytes, the file in flight, failures and elapsed time. fraction() weighs by bytes when sizes are known, otherwise by count; a failed asset counts as done, so a broken file cannot hold a loading screen forever.
- Each group keeps at most 16 loads in flight.
- A folder expands recursively (skipping text, config, script and dot files).
- A scene expands to the asset paths quoted inside it.
- Formats the asset server does not handle can be preloaded by registering an
AssetKindHandlerinAssetKindHandlers(audio registers one forogg,wav,mp3andflac). LoadZone { group, paths, radius, unload_radius }loads a group when aLoadZoneTargetentity comes withinradius(default 512) and unloads it beyondunload_radius(768). Zones do nothing in the editor.
Interpreted scripts reach the same API through declared functions (preload, preload_scene, activate_scene, load_progress, load_ready, ...); a Rust script uses AssetLoads directly.
The .rpak archive
An exported game's assets are one .rpak file.
Format (version 2).
- A 32-byte header:
RPAK, version, flags (bit 0: the index is zstd-compressed), index offset and compressed and uncompressed index sizes. - The data section.
- The index: per entry, the path, offset, compressed and uncompressed size, compression (stored or zstd), flags and a CRC32.
- An optional 16-byte footer (
total size,RPAK), which is what lets an archive be appended to an executable and found from the end.
Readers use a byte, file or memory-mapped backend (RpakArchive).
What goes in. Packing does not copy the whole project. It starts from project.toml (with its [editor] section stripped), the main scene, the icon, autoload scenes, language packs and themes, and quoted paths inside Rust scripts, and follows references breadth-first: quoted paths in scenes, the JSON inside .glb files and .rvg scenes, bound .material files, the .rvg beside each .glb, terrain cluster files, and sidecars (.wgsl.meta, .svg.toml). A file nothing reaches is not shipped. The export window's Files tab can pick the set by hand instead (pack_selected_with_progress).
Compression. Each entry is zstd-compressed at the chosen level (default 3, 1 to 22), except formats that are already compressed (png, jpg, jpeg, webp, gif, ogg, mp3, flac, rmip, ktx2, basis, dds, svgz, zst, zip), which are stored, as is any entry zstd fails to shrink.
Export order. ensure_virtual_geometry brings every .rvg sidecar up to date, the archive is packed, runtime-irrelevant entries are stripped, and then, if enabled, .glb entries are mesh-optimised and given generated LOD files. Those last two apply to .glb only; an .rvg is already optimised and has its own detail levels.
Where it goes.
| Export | Archive |
|---|---|
| Separate files | <game>.rpak beside the executable |
| Single binary | Appended to the executable (beside it inside a macOS .app) |
| Android | assets/game.rpak |
| iOS | game.rpak in the app bundle |
| Web | game.rpak beside the page |
| Dedicated server | server.rpak, with only data formats (no textures, models or audio) |
There is no command-line packer; archives are built by the export window. See Asset Packing.