Expand description
Opt-in full-screen post-processing: bloom, tonemapping, grading, vignette and optional film grain, chromatic aberration and scanlines.
Games choose a PostFx with set_post_fx. The setting is sticky: it
stays active across frames (and clear_background) until replaced, so a game
usually sets it once per scene. PostFx::off() (the default) restores the
original direct-to-screen path with zero extra GPU work.
While post-processing is active, the world is drawn into an offscreen target. At the world/HUD boundary the hosts resolve that target, run the bloom chain and composite the graded image to the screen; every later draw (HUD, menus, the Controls editor) is drawn directly on top, crisp, un-bloomed and un-vignetted. The boundary is the first of:
- an explicit
post_fx_hud_begin; set_world_colors(false)while world colors are enabled;set_default_camera()while world colors are enabled (that is, after aset_camerain the same frame).
The last two follow the existing world-palette boundary and can be disabled
with PostFx::auto_hud. Without a boundary, the whole frame is
post-processed. Only the first boundary in a frame counts.
Player preferences and accessibility always win over authored settings:
- An explicit Low quality choice (Details,
?quality=loworFERRAVEX_QUALITY=low) disables post-processing. Medium uses a four-level bloom chain; High uses five levels. Without a player choice, an authoredset_quality(High)selects High and anything else selects Medium. - Sustained adaptive-performance pressure (level 2 and above) caps the tier at Medium.
- Reduced flash caps bloom intensity at
REDUCED_FLASH_BLOOMand disables grain and chromatic aberration.
Developers can force a preset for a session with FERRAVEX_POST=off|subtle| neon|warm-film|crt (native) or ?post=… (browser) without editing a game.
use ferravex_render::{input, post::{self, PostFx, PostTier}};
post::set_post_fx(PostFx::neon().vignette(0.25, 0.6));
let status = input::host_frame(1. / 60., 320, 200, || {
ferravex_render::clear_background(ferravex_render::BLACK);
// World: bright additive accents feed the bloom.
post::glow_circle(160., 100., 24., ferravex_render::ORANGE, 1.5);
// HUD: drawn after the boundary, it stays crisp.
post::post_fx_hud_begin();
ferravex_render::draw_rectangle(8., 8., 40., 6., ferravex_render::WHITE);
post::post_fx_status()
});
assert_ne!(status.tier, PostTier::Off);
post::set_post_fx(PostFx::off());Structs§
- PostFx
- Authored post-processing settings. Start from a preset and adjust with the builder methods. Values are sanitized when applied: non-finite numbers use the neutral value and every field is clamped to its documented range.
- Post
Status - Effective post-processing state for the current settings and preferences.
Enums§
- Post
Tier - Effective post-processing tier after preferences, accessibility and adaptive performance are applied.
- Tonemap
- How bloom and over-bright scene values are mapped to the display.
Constants§
- MAX_
BLOOM_ LEVELS - Maximum bloom chain length used by the High tier.
- POST_
COMPOSITE_ FRAGMENT_ BODY - Final composite: bloom upsample, exposure, tonemap, lift/gamma/gain,
power-law contrast, saturation, vignette, scanlines, grain and a static
sub-LSB dither (interleaved gradient noise) against 8-bit banding.
u_texel.xyis the bloom texel size andu_texel.zwthe scene texel size. - POST_
DOWN_ FRAGMENT_ BODY - Dual-filter downsample.
u_texel.xyis the source texel size;u_texel.zselects the bright-pass prefilter (thresholdu_bloom.x, kneeu_bloom.y). - POST_
FRAME_ FLOATS - Number of
f32values in the resolved per-frame host block. - POST_
UP_ FRAGMENT_ BODY - Dual-filter tent upsample.
u_texel.xyis the source texel size andu_texel.zthe radius; hosts additively blend into the larger level. - POST_
VERTEX_ BODY - Full-screen triangle; no vertex attributes. Hosts prepend their GLSL version/precision header.
- REDUCED_
FLASH_ BLOOM - Bloom intensity cap applied while the player requests reduced flash.
Functions§
- glow_
circle - Soft additive radial glow in the current camera’s 2D coordinates (z = 0).
intensitymultiplies RGB and may exceed one: over-bright values bloom more strongly on half-float targets. Uses 112 unlit triangles; the world palette still applies inside a world camera. - post_fx
- Current authored settings (before session overrides and preferences).
- post_
fx_ hud_ begin - Mark the world/HUD boundary explicitly. Draws after this call go straight to the screen on top of the post-processed world. Returns true when this call recorded the frame’s boundary; false if post-processing is off or a boundary already exists in this frame.
- post_
fx_ status - Effective tier, bloom levels and capped settings for the current state.
- set_
post_ fx - Replace the sticky post-processing settings. Takes effect for the current
frame’s composite; use
PostFx::off()to return to direct rendering. - with_
glow - Draw immediate primitives (rectangles, circles, lines, text, meshes) with
additive blending inside
draw, so bright shapes accumulate light and feed the bloom. Equivalent toEffectBlend::Additivefor immediate geometry; works with post-processing off as plain additive blending.