Expand description
The camera layer of crate::effects’ four-layer order, as a file.
RenderEffects is what a frame draws; CameraStack is what a view
asks for, written down. Topic 48’s camera layer (docs/notes/rendering.md)
is per view and is a file naming which passes run and with what parameters,
and the toggle layering the same notes record puts that layer at the top
of the resolution order, above the player’s [engine.video] clamp; this module is
the reader and the writer of that file, and CameraStack::compile is the
step that turns it into the bits EffectRequest::camera carries.
use crcbl_render::stack::CameraStack;
use crcbl_render::RenderEffects;
let stack = CameraStack::from_ron(
"(shadows: Some(()), ambient_occlusion: Some(()), bloom: Some(()))",
)?;
assert_eq!(
stack.compile(),
RenderEffects::SHADOWS
.union(RenderEffects::AMBIENT_OCCLUSION)
.union(RenderEffects::BLOOM),
);§A pass is present or absent, and that is the whole file
Every field is an Option of a pass, and compile
sets that pass’s bit exactly where the option is Some — which is the same
statement crate::effects makes about the renderer: an effect that is off is
a frame with fewer passes, never a shader branch. A field a file leaves out
is None, so the shortest legal stack is () and draws nothing.
§The pass types are empty, and each says what it would carry
Every pass here but AntialiasingPass is a field-less struct. That is not
a placeholder for parameters this module forgot: the renderer’s per-pass
parameters are the setters a caller already has —
ForwardRenderer::set_fog, set_exposure, set_exposure_adaptation,
set_tonemap_curve — and each of those takes a type that belongs to the
pass rather than to this file. Giving a pass a parameter here means giving
that type a serialized form and one owner, which is a slice of its own;
docs/backlog.md lists which passes are waiting for one.
AntialiasingPass is the exception because the thing it names is not a
pass but a slot. Antialiasing holds the argument: there is one
resolve, RenderEffects::ANTIALIASING and RenderEffects::CMAA2 are two
bits of one ladder rung rather than two independent switches, and
EffectRequest::resolve clears the whole slot before it fills it. So this
file has one antialiasing field naming a tier, and no per-tier field
beside it: two spellings of one rung is exactly what the antialiasing
ladder refused when it collapsed the two bits into one
(docs/notes/rendering.md).
Structs§
- Ambient
Occlusion Pass - Screen-space ambient occlusion —
RenderEffects::AMBIENT_OCCLUSION. - Antialiasing
Pass - The frame’s one antialiasing resolve, and which tier fills it.
- Auto
Exposure Pass - Auto-exposure —
RenderEffects::AUTO_EXPOSURE. - Bloom
Pass - The bloom chain —
RenderEffects::BLOOM. - Camera
Stack - What one view asks its frame to draw, as a file.
- Contact
Shadows Pass - Screen-space contact shadows —
RenderEffects::CONTACT_SHADOWS. - Reflections
Pass - Screen-space reflections —
RenderEffects::REFLECTIONS. - Shadows
Pass - The shadow atlas —
RenderEffects::SHADOWS. - Stack
Error - Why a string is not a
CameraStack. - Volumetric
FogPass - Volumetric fog —
RenderEffects::VOLUMETRIC_FOG.