Render Pipeline
How a frame is put together: Bevy's PBR renderer underneath, the render phases Renzora slots its own passes into, how effect settings reach a camera, and the project-wide switches (graphics tier, render scale, backend) that decide what runs.
The base renderer
Renzora does not have a renderer of its own beneath Bevy's. A 3D camera renders through Bevy 0.20's PBR pipeline: clustered forward lighting (or Bevy's G-buffer in deferred mode), an HDR target, then tonemapping. Every shader in that path is WESL; see Shaders.
Everything Renzora adds sits on top, in three forms:
| Form | Examples | How it renders |
|---|---|---|
| Wrappers around Bevy components | renzora_bloom_effect, renzora_dof, renzora_ssao, renzora_ssr, renzora_motion_blur, renzora_auto_exposure, renzora_tonemapping, renzora_antialiasing, renzora_atmosphere, renzora_skybox, renzora_environment_map, renzora_forward_decal, renzora_distance_fog, renzora_volumetric_fog, renzora_oit | An authored settings component (BloomSettings, OitSettings, ...) is copied onto the rendering cameras as the stock Bevy component (Bloom, OrderIndependentTransparencySettings, ...). No pass of their own. |
| Render-composition passes | renzora_postprocess (shader-file effects), renzora_ssil, renzora_atmosphere's sun glare, renzora_clouds' sky probe | A type implementing RenderPass, registered into one ordered registry and run by Renzora's phase dispatchers. |
| Renderers with their own pipelines | renzora_virtual_geometry, renzora_planar_reflection, renzora_solari, renzora_particles | Their own render-world systems and pipelines. See their pages. |
Device features and the backend
renzora_runtime::platform_wgpu_settings builds the WgpuSettings before DefaultPlugins:
- On desktop it requests
POLYGON_MODE_LINE(the wireframe viewport mode), except on the GL backend, which cannot create a device with it. - When the runtime is built with Solari and
raytracing_supported()finds the adapter can ray trace, it adds Bevy Solari's required features and insertsGpuRaytracing { enabled: true }. The probe opens a throwaway adapter on the same backend the renderer will use. Requesting a feature the adapter lacks would fail device creation, so on any other GPU nothing extra is asked for. See Solari. - Android always uses Vulkan. On the web the browser's defaults pick WebGPU or WebGL2, with
WgpuSettingsPriority::Functionalityso the adapter's real limits are used; the WebGPU baseline of 12 uniform buffers per stage is one short of the forward mesh view layout.
wgpu fixes the backend when the renderer is created, so the choice is made once per process (renzora_runtime::renderer_backend::select) and a change applies on the next launch. Whose setting it is depends on what is running:
| Process | Setting |
|---|---|
| The editor (and its companion process) | The user's preference, [editor] renderer_backend in ~/.renzora/settings.toml |
| A game: a shipped build, the Play child, a host or VR session | The project's [rendering] backend |
[rendering]
backend = "auto" # auto (default), dx12, vulkan, metal or gl
auto resolves to Vulkan on Windows, Linux and the BSDs, and Metal on Apple platforms. A backend the platform cannot create (DX12 on Linux) is replaced by auto with a warning, since asking wgpu for it would find no adapter and panic. A game reads this key before any engine plugin builds, through renzora_runtime::early_project, from the same sources and in the same order as the rest of its project: the rpak (embedded, beside the binary, or --rpak), then --project, then project.toml in the working directory.
Prepasses are fixed at camera spawn
Bevy specializes a camera's prepass pipeline at its first render and cannot grow its attachment list afterwards: adding a prepass later is a wgpu validation error. So every rendering camera is spawned with NormalPrepass, DepthPrepass and MotionVectorPrepass already on (renzora_engine::camera::spawn_editor_camera, and rehydrate_cameras for a game's scene camera), plus Hdr and Msaa::Off. NormalPrepass is what lets masked materials compile their prepass, depth and motion vectors feed TAA and the screen-space effects, and Msaa::Off is required because the atmosphere binds depth as non-multisampled.
The same reasoning keeps other bindings resident instead of toggled: a camera gets a zero-strength DistanceFog at spawn (not on the web, where that uniform slot cannot be spared), and the primary camera carries its AtmosphereEnvironmentMapLight from the start. An effect that would otherwise add or remove one of these components only ever updates it.
DeferredPrepass is the exception, added in PostUpdate by ensure_deferred_prepass_on_cameras once the project's rendering mode resolves to deferred.
Inactive cameras give their textures back
Bevy keeps every per-view texture (the main colour pair, depth, prepass and G-buffer, bloom, TAA history, and every pass's own) on an inactive camera's render entity, because its prepare systems only visit cameras that are still extracted. In the editor that is every preview and capture camera that ever rendered: nine sets of frame textures on the Bistro with two cameras drawing.
renzora_runtime's idle_cameras releases them. A camera inactive for two seconds loses SyncToRenderWorld and RenderEntity, so Bevy despawns its render entity with everything on it; when the camera is made active again, the marker goes back on in Last of the same frame and extraction gives it a fresh render entity before it renders. Its per-view history (TAA, auto exposure, SSIL) starts over, as for a new camera. Both components must come off together: Bevy's sync leaves RenderEntity behind when the marker goes, and adding the marker back while it is there panics.
Forward and deferred
[rendering]
mode = "auto" # auto (default), forward or deferred
RenderingMode::Auto currently resolves to forward on every platform; deferred is opt-in with mode = "deferred". SSR and SSIL read the G-buffer that only deferred writes, so in forward their switches stay off and their Inspector sections say so. A scene saved with either on keeps the setting, and the effect returns once the project is deferred.
Render phases
Bevy 0.20 has no render graph: a 3D view renders as systems in the render app's Core3d schedule. Renzora adds four system sets, RenderPhase (defined in renzora_scene_api), and anchors them once, in PostProcessCorePlugin (renzora_render_api::postprocess), against Bevy's own passes:
| Phase | Placed in | Image | For |
|---|---|---|---|
Gi | Core3dSystems::EarlyPostProcess, before TAA | linear HDR | indirect light, sky probes: work that must enter TAA's history |
HdrPost | Core3dSystems::PostProcess, after TAA, before tonemapping | HDR | glare and other HDR effects |
LdrPost | Core3dSystems::PostProcess, after tonemapping, before FXAA and SMAA | LDR | the shader-file post effects |
Overlay | Core3dSystems::PostProcess, after FXAA, SMAA and LdrPost | final | debug views and overlays |
HdrPost is in PostProcess rather than EarlyPostProcess because DLSS runs in EarlyPostProcess with no set of its own to order against. An HDR pass there could land before it, and DLSS would then treat that pass's output as part of its noisy input: the sun glare flickered with Solari on. PostProcess runs after every upscaler has finished.
The anti-aliasing anchors are compiled only with the antialiasing feature, because the exporter can strip anti-aliasing from a game. Ordering against an anchor that is not in the schedule is a no-op, so the phases still work without it.
The 2D pipeline (Core2d) gets LdrPost and Overlay too, anchored after its tonemapping, so shader-file effects work on 2D games. Gi and HdrPost stay 3D-only: their passes read depth and prepass textures a 2D camera never makes.
The composition registry
Passes do not each add a system. They register into one render-world resource, RenderComposition, which keeps its entries sorted by (phase, order), and one dispatcher system per phase runs every enabled entry for each view:
pub trait RenderPass: Send + Sync + 'static {
fn run(
&self,
world: &World,
render_context: &mut RenderContext,
view_target: &ViewTarget,
view_entity: Entity,
);
}
pub struct RenderPassEntry {
pub id: &'static str, // e.g. "post_effects"
pub phase: RenderPhase,
pub order: f32, // lower runs first within the phase
pub enabled: bool,
// plus the type-erased handler
}
A pass registers on the render sub-app:
use renzora::postprocess::{RenderCompositionAppExt, RenderPass};
use renzora::RenderPhase;
app.sub_app_mut(RenderApp)
.add_systems(RenderStartup, init_my_pipeline)
.add_render_pass("myplugin.glow", RenderPhase::HdrPost, 0.0, MyGlowPass);
run is called once per view. The pass reads its pipeline and extracted data from world, records on render_context (the encoder is submitted when the dispatcher ends), uses view_target.post_process_write() for the source and destination of a fullscreen pass, and returns early on a view without its settings component. That early return is what makes an inactive effect cost nothing.
The dispatchers and the phase anchoring come from PostProcessCorePlugin. Registering a pass without that plugin installed silently does nothing, because registration and dispatch are wired in different places; the plugin is idempotent, so add it if you register a pass. It also embeds postprocess_copy.wesl, a pass-through shader for copying the live frame into a texture of your own (also served at its old path, embedded://renzora/postprocess_copy.wesl).
Each entry is timed under its id with Bevy's render diagnostics, so the profiler shows what each pass costs.
The engine's own registrations:
id | Phase | Order | Crate |
|---|---|---|---|
cloud_sky_probe | Gi | -100 | renzora_clouds |
ssil | Gi | 0 | renzora_ssil |
sun_glare | HdrPost | 0 | renzora_atmosphere |
post_effects | LdrPost | 0 | renzora_postprocess |
RenderComposition and RenderPass live in the shared contract image, so a native plugin's pass sorts in the same list as the engine's. A plugin table's priority has nothing to do with render order; only phase and order do.
For a single fullscreen fragment effect you do not need any of this: write it as an effect file and put it on a Post Process component. See Post-Processing Effects.
A pass that needs a component in the render world extracts it the Bevy 0.20 way: ExtractComponent and SyncComponent are generic over the target app, so implement ExtractComponent<RenderApp>.
EffectRouting: settings onto cameras
Effect settings are authored on a scene entity (usually the World Environment, or the scene camera) and copied onto the cameras that render. The table that says which is which is a resource in renzora_scene_api:
#[derive(Resource, Default, Debug)]
pub struct EffectRouting {
pub routes: Vec<(Entity, Vec<Entity>)>, // (target camera, source entities)
}
Each effect crate runs a small sync system: for every target, the first source carrying its settings component wins, and the stock Bevy component is inserted on the target, or removed when no source has it.
Who fills the table:
- A game (
renzora_engine::update_runtime_effect_routing): one route. The target is the active scene camera, the firstSceneCamerathat is bothDefaultCameraand active, else the first active one. The sources are that camera plus every named, non-camera entity that is not hidden chrome, a UI node or drawn content (meshes and sprites). - The editor (
renzora_viewport::effect_routing): each viewport camera takes theDefaultCameraplus the same set of global sources, and the camera preview takes the camera being previewed. Play runs the game as its own process, so the editor never re-targets an authored scene camera.
Both builders sort the sources by a stable key and write the table only when it differs. An unsorted query order changes with archetype churn, and every spurious change re-runs every effect's sync and re-extracts its component.
Indirect light and reflections
- SSIL (
renzora_ssil): one bounce of screen-space indirect light, aGi-phase pass. Needs deferred, and runs only on the High tier. See SSIL. - Solari (
renzora_solari): Bevy Solari's ray-traced lighting, the engine's only ray-traced GI, active only whereGpuRaytracingis set. While it lights a camera, the camera carriesSolariLitandrenzora_ssaoremoves SSAO from it, since Solari traces its own occlusion. See Solari. - Planar reflections: see Planar Reflections.
Reflection probes
The Reflection Probe entity preset (Lighting category) spawns LightProbe, ParallaxCorrection::Auto and a ReflectionProbeSource { path, intensity }, at a scale of 4. The probe's Transform is the box it influences. ReflectionProbeSource (in renzora_scene_api) is what persists: a project-relative image path (an equirectangular HDR is reprojected to a cube, a cube container is used as is) and an intensity, default 1.0.
renzora_environment_map attaches Bevy's GeneratedEnvironmentMapLight only once a valid power-of-two cube is ready. Bevy's filter runs the moment that component exists and would otherwise filter the 1x1 default handle.
Environment maps filter only while their input changes
Bevy re-filters every GeneratedEnvironmentMapLight into radiance and irradiance maps on every frame, whether or not anything changed. renzora_environment_map::filter_gate gives each map a short filter window, re-armed by anything that changes its input (the component, its source image, its camera turning active, for the sky probe the sun or atmosphere changing, and new or re-uploaded output images) and freezes it outside that window by removing the extracted RenderEnvironmentMap in the render world. The main-world component is never touched, so the bind group layout it holds in place stays put. The window does not count down while pipelines are still compiling: the sky is black until the atmosphere's pipelines are ready, and a window spent entirely in compilation would freeze an empty map.
GPU culling
renzora_engine::gpu_culling tags every mesh the GPU can cull with Bevy's NoCpuCulling as it appears, so it is culled on the GPU against the camera and every shadow view instead of on the CPU each frame. Two kinds stay on CPU culling:
- Skinned meshes, because the CPU culls them with bounds that follow the pose.
- Meshes whose
VisibilityClasslacksMesh3d: virtual geometry and Solari's see-through glass take a mesh out of Bevy's mesh passes that way, and the GPU-culled path never looks at the class, so a tagged one would be drawn twice.
A tagged mesh's ViewVisibility follows InheritedVisibility, so picking and ray casts still see it as shown unless hidden. To keep CPU culling on a mesh of your own, take Mesh3d out of its VisibilityClass. On WebGL2, which cannot cull on the GPU, tagged meshes are drawn unculled.
Bevy's GPU light clusters start larger than Bevy's defaults (renzora_lighting): 4096 Z slices and 262,144 light indices. Bevy only grows those lists after a GPU overflow has been read back, so a scene with dozens of point lights would otherwise render a few frames of wrong lighting each time more lights came into view.
Order-independent transparency
renzora_oit::OitSettings (default layer_count: 8, alpha_threshold: 0.0, enabled: true) is routed like any wrapper effect and becomes Bevy's OrderIndependentTransparencySettings on the camera. MSAA cannot run alongside it (see Camera).
SSAO
SSAO is a section of the WorldEnvironment component (renzora_world_api), not a component of its own; renzora_ssao turns it into Bevy's ScreenSpaceAmbientOcclusion on the routed cameras.
pub struct SsaoSection {
pub enabled: bool,
pub quality: SsaoQuality, // Low 4 spp, Medium 8, High 18 (default), Ultra 54, Custom
pub slice_count: u32, // Custom only, default 3
pub samples_per_slice_side: u32, // Custom only, default 3
pub constant_object_thickness: f32, // default 0.25
}
Off removes the component outright: unlike the bindings above, SSAO's pipeline key reads the component directly, so toggling it by presence is safe. Values are clamped on the way to Bevy (slice_count 1 to 16, samples_per_slice_side 1 to 8) so a hand-edited scene cannot produce an empty or enormous pass. A camera with SolariLit or SsilLit gets no SSAO whatever the section says (both carry their own occlusion), and the section keeps its value for when they stop.
Graphics quality tiers
Most of an idle frame's cost is fullscreen, resolution-bound work on the active camera, not geometry: one cube costs the same as a level. The tier is one switch that trades those passes for frame rate. Its rules are methods on GraphicsQuality (renzora_project_api::quality):
| Tier | Sky probe face | Shadow map | Clouds | Atmosphere | SSAO | SSIL | Auto exposure | Bloom | TAA |
|---|---|---|---|---|---|---|---|---|---|
| High | 256 | 2048 | full step count | Raymarched | on | on | on | on | on |
| Medium (default) | 128 | 1024 | capped steps | LookupTexture | off | off | on | on | on |
| Low | 64 | 512 | off | LookupTexture | off | off | off | off | off |
The shadow map size is DirectionalLightShadowMap, the per-cascade resolution shared by every directional light.
[rendering]
graphics_quality = "Medium" # Low | Medium | High
The key is outside [editor], so an export keeps it; an unknown or missing value reads as Medium. It is edited in Settings > Project > Rendering.
renzora_engine::graphics_quality applies it in every session, game and editor alike, so the viewport shows what the game will run:
sync_graphics_qualitycopiesCurrentProject.config.rendering.graphics_qualityintoResolvedGraphicsQualityevery frame, writing only on change. A script or settings menu that changes the config is picked up next frame.enforce_graphics_qualityruns inPostUpdate, after theUpdaterouters, so it has the last word. It governs every 3D camera in a game and only theViewportCameras in the editor, never anIsolatedCamera.rebuild_mismatched_sky_probesresizes the sky probe (below).
The tier is a ceiling, not an authority: it only switches things off. Bloom, TAA, auto exposure and SSAO are removed from the camera; the atmosphere's rendering_method is reassigned; the shadow map resource is resized. When the tier changes it marks EffectRouting changed, so the routers re-apply every effect from its untouched scene source and the enforcer then strips what the new tier still forbids. In the editor only the save-excluded viewport cameras are stripped, so "bloom off" can never be baked into a saved scene.
Every one of these mutations is one a router already performs at runtime, so none grows a camera's bind group layout after its first render.
The sky probe resizes over two frames. Resizing AtmosphereEnvironmentMapLight in place makes Bevy drop and rebuild the derived maps, and if that lands in the same command flush as Bevy's unordered generate_environment_map_light the filter can see a new cube beside an old mip chain and fail on a missing mip. So on the frame the size stops matching, the probe is removed, and the next PostUpdate adds it back at the new size. The cost is one frame with no sky light on that camera.
The integrated-GPU hint
At startup renzora_runtime records whether the adapter is integrated (GpuIsIntegrated). If it is and the tier is not Low, the editor raises a toast suggesting Low. It never changes the tier itself, and it stores no "already asked" flag: the condition clears itself once the tier is Low.
Render scale
[rendering]
render_scale = 1.0 # fraction of the logical window
A game renders its 3D camera into an offscreen image sized render_scale times the logical window and upscales it into the window, with the UI composited on top at native resolution (renzora_runtime::render_scale). Because it is the logical size, 1.0 already renders at design resolution on a high-DPI display, where the physical framebuffer is larger, and is a plain render to the window on a 1.0-DPI display. Below 1.0 it is a performance slider; at or above the display's scale factor it saturates to native and never supersamples.
It is game-only (the editor has per-camera render resolution instead) and stands down while a non-Disabled [viewport] stretch_mode owns the present pass. RenderingConfig's Default is written by hand so that a project with no [rendering] table gets 1.0, not a zero-pixel target.
Frame pacing
[window] vsync (default true) maps to PresentMode::AutoVsync or AutoNoVsync. The game applies it (renzora_runtime::window_config), and the editor applies the same key to its own window (renzora_editor_framework), so turning it off uncaps both: there is no separate editor vsync. Turn it off when profiling: a vsynced frame rate hides the true frame cost.
[window] max_fps (default 0, unlimited) holds a game to a fixed rate on any monitor (renzora_runtime::frame_limit). It is registered only in a game, never for the editor window. The wait runs in Last, so the next frame reads input gathered after the wait; it sleeps until a millisecond before the deadline and spins the rest, and paces from the deadline rather than from wake-up so the rate does not drift. Both keys are read from CurrentProject every frame, so a running game can change them:
fn cap_to_thirty(mut project: ResMut<renzora::CurrentProject>) {
project.config.window.max_fps = 30;
}
Related
- Post-Processing Effects: effect files and the shader contract.
- Camera: viewport and game cameras, anti-aliasing and exposure.
- Shadows
- Sky and Atmosphere
- Architecture: where the render crates sit in the contract hierarchy.