Skip to main content

Module stack

Module stack 

Source
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§

AmbientOcclusionPass
Screen-space ambient occlusion — RenderEffects::AMBIENT_OCCLUSION.
AntialiasingPass
The frame’s one antialiasing resolve, and which tier fills it.
AutoExposurePass
Auto-exposure — RenderEffects::AUTO_EXPOSURE.
BloomPass
The bloom chain — RenderEffects::BLOOM.
CameraStack
What one view asks its frame to draw, as a file.
ContactShadowsPass
Screen-space contact shadows — RenderEffects::CONTACT_SHADOWS.
ReflectionsPass
Screen-space reflections — RenderEffects::REFLECTIONS.
ShadowsPass
The shadow atlas — RenderEffects::SHADOWS.
StackError
Why a string is not a CameraStack.
VolumetricFogPass
Volumetric fog — RenderEffects::VOLUMETRIC_FOG.