Drawables, Helpers & Diagnostics
All extra stage drawables render through the existing sprite and surface shaders — a stage that does not use them allocates zero atlases, buffers, or passes (StageRenderer::drawable_report).
Tilemaps
A node carries a TileMap (TileSet with texture, tile size, columns, margin, spacing; world tile size; chunk_size, default 16). Tile (0, 0) sits at the node's origin, growing in any direction including negative coordinates. Each Tile has a tileset index, 8-way Orientation (Tile::rotated), and RGBA8 tint.
- Chunked & culled — Each chunk builds its quads once when first visible and rebuilds only when edited (
TileMap::builds); empty chunks drop automatically. Only visible chunks emit instances, so draw counts follow visible batches rather than total map size (DrawList::chunks,chunks_culled,tiles). - Lit maps take the surface path with flat normals; opaque and cutout maps write depth.
Particles
A node carries an Emitter: texture, atlas frame mode (ParticleFrames), blend, rate and Stage::emit_burst, lifetime/velocity ranges, acceleration, exponential drag, size and colour Curves, rotation/spin, world_space or local space, billboard, sorting, and optional ParticleGround (bounce and friction).
- Fixed pool — One
Vecofmax_particlesallocated on creation;Stage::advance(dt)steps and compacts dead particles in place with zero per-frame allocations, driven by a deterministic SplitMix64seed. - Host-simulated particles —
Stage::set_particles(node, &[HostParticle])draws externally simulated particles in the emitter's batch.
World-Space Text
Stage::create_font(bytes) registers a TrueType/OpenType font. Text draws shaped glyphs (harfrust) as quads in the node's plane or billboarded, with size, colour, anchor, align, max_width wrapping, line_spacing, and texels_per_unit. Stage::layout_text and text_size query layout headlessly.
- Stage glyph atlas —
engine-stage-renderkeeps its own 1024×1024 shelf-packed atlas (independent ofengine-ui), rasterizing unhintedskrifaoutlines viaengine-gfx's FreeType-port rasterizer and uploading dirty rows within the frame budget.
Debug Lines
Stage::debug_line, debug_arrow, debug_box, debug_rect, and debug_circle submit immediate screen-width ribbons (DebugStyle { colour, width, depth_test, layers }) drawn after all other steps. Stage::advance (or clear_debug) clears them each frame.
Sprite Animation & Time
Clip&Animator—Clipholds timed atlas frames withLoopMode(Loop,Once,PingPong;Clip::stripbuilds uniform strips).Stage::play(node, clip)drives the node's spriteatlasduringStage::advance(dt)and queuesFinished/Loopedevents readable viadrain_animation_events.Stage::advance(dt)— Clears debug lines, steps sprite animations, and simulates particles.
Game Loop Helpers
The stage owns no loop; two helpers cover common host needs:
engine_core::FixedClock— Value-type fixed-timestep accumulator (advance(elapsed)). Drops the first frame's delta to avoid phase shift, clamps frame time (with_max_frame, default0.25s) and steps (with_max_steps, default4), supportspause/resume, and exposesfraction()for render interpolation.StageRenderer::pipelines_settled()— Returnstrueonce the lastNconsecutiverecordcalls (default 8) returnedReady, letting hosts hold gameplay until initial pipelines compile (set_readiness(Readiness::with(settle, warmup))).
Comparing Captures
Pixel difference is the maximum per-channel RGBA delta (0..=255), reporting mean, max, differing count, percentage above threshold (default 8), and mean_channel:
- Rust tests (
engine-image-diff) — Dev-dependency comparing two RGBA8 buffers withcompare(w, h, a, b, &Options { threshold, region, masks, step }). - CLI (
bun build/compare-images.ts <a> <b>) — Compares two PNG files or two directories recursively. Supports--mask x0,y0,x1,y1,--region,--step N,--skip N,--threshold N,--out DIR(amplified diff images),--json,--max-mean N, and--max-over PCT.
Measuring GPU Pass Times
StageRenderer::set_gpu_timing(device, true) enables device pass timers (Device::set_pass_timing, runtime equivalent of ENGINE_PASS_TIMES). When enabled, gpu_timings() reports per-frame mean PassTiming { pass, duration, vertex } across stage shadows, stage camera, stage resolve, stage post, and stage clear (1–2 frames behind record). On WebGPU, pass timing requires starting with ENGINE_PASS_TIMES.