pub fn render_raytrace_rgba(
scene: &RayTraceScene,
frame: &RayTraceFrame<'_>,
out: &mut Vec<u8>,
) -> Result<(), String>Expand description
Renders a ray-traced RGBA frame on the CPU.
This is the CPU reference and the Canvas 2D backend’s renderer. It does
not re-implement traversal or shading: each pixel builds a Ray — a
stack value, so no allocation happens per pixel, per bounce, or per
frame — and hands it to RayTraceScene::trace_with_bounces, which
runs the scene’s own bounding volume hierarchy and the real
LightingUniforms shading. The two GPU backends implement the same
math in shader form against the packed buffers; they are the only
duplicates, and they must agree with this path rather than with each
other.
The frame is described by a [FrameBasis], a stack value built by the
same validator pack_raytrace_frame uses, so this path never packs a
GPU buffer, never re-encodes the scene, and allocates nothing at all
beyond the caller-owned out. A steady-state frame therefore performs
exactly one heap operation: none.
Each pixel traces samples_per_axis squared supersampled rays, averages
them, clamps the linear color to [0, 1], applies the 1 / 2.2 gamma
curve, and writes an opaque alpha. Rows are emitted top-down.
Frame inputs arrive through the same RayTraceFrame parameter type
accepted by pack_raytrace_frame. The scene and mutable output remain
separate, so the descriptor itself contains only read-only frame state.
§Arguments
&RayTraceScene- The scene to render.&RayTraceFrame<'_>- The camera, lights, settings, and dimensions to render.&mut Vec<u8>- The destination RGBA buffer, cleared and reused.
§Returns
Result<(), String>-Okonce the frame is written, or the reason the frame cannot be rendered.