Struct PostFx

Source
pub struct PostFx {
Show 17 fields pub bloom_intensity: f32, pub bloom_threshold: f32, pub bloom_knee: f32, pub bloom_radius: f32, pub tonemap: Tonemap, pub exposure: f32, pub contrast: f32, pub saturation: f32, pub lift: [f32; 3], pub gamma: [f32; 3], pub gain: [f32; 3], pub vignette: f32, pub vignette_softness: f32, pub grain: f32, pub aberration: f32, pub scanlines: f32, pub auto_hud: bool,
}
Expand description

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.

use ferravex_render::post::{PostFx, Tonemap};
let fx = PostFx::subtle()
    .bloom(0.5, 0.7, 1.2)
    .tint(ferravex_render::Color::new(1.05, 1., 0.92, 1.))
    .vignette(0.3, 0.5)
    .tonemap(Tonemap::Soft);
assert!(!fx.is_off());
assert!(PostFx::off().is_off());

Fields§

§bloom_intensity: f32

Bloom strength, 0–8. Zero skips the bloom chain. The chain is normalized by its level count, so a value keeps the same overall energy on Medium and High; small bright shapes need roughly 1–3 for a clearly visible halo.

§bloom_threshold: f32

Brightness (max RGB channel) where bloom starts, 0–4.

§bloom_knee: f32

Soft-threshold width around the threshold, 0–1.

§bloom_radius: f32

Upsample filter spread, 0.25–3. One is the dual-filter default.

§tonemap: Tonemap§exposure: f32

Scene multiplier before tonemapping, 0–8.

§contrast: f32

Power-law contrast around mid-grey (0.5 * (2c)^contrast), 0–2. Black stays black, so dark palettes keep their relative detail.

§saturation: f32

Saturation, 0 (greyscale) – 2.

§lift: [f32; 3]

Shadow lift per channel, -0.5–0.5.

§gamma: [f32; 3]

Midtone gamma per channel, 0.2–5. Above one brightens.

§gain: [f32; 3]

Highlight gain (tint) per channel, 0–4.

§vignette: f32

Corner darkening, 0–1.

§vignette_softness: f32

Vignette falloff width, 0.05 (tight corners) – 1 (from the center).

§grain: f32

Animated film grain amplitude, 0–0.25. Default off.

§aberration: f32

Radial chromatic aberration, 0–1 (1 ≈ 1% of the screen). Default off.

§scanlines: f32

Scanline darkening, 0–1, one line every three logical pixels. Default off.

§auto_hud: bool

Treat set_world_colors(false) / set_default_camera() as the HUD boundary. Default true.

Implementations§

Source§

impl PostFx

Source

pub const fn off() -> PostFx

Neutral settings: no post-processing and no extra GPU work.

Source

pub const fn subtle() -> PostFx

Gentle glow on the brightest pixels, slight contrast/saturation and a light vignette. Unlit areas keep their authored colors.

Source

pub const fn neon() -> PostFx

Strong, wide glow for dark scenes with saturated emissive shapes.

Source

pub const fn warm_film() -> PostFx

Filmic curve, warm highlights, lifted shadows, soft vignette and a hint of grain.

Source

pub const fn crt() -> PostFx

Arcade monitor: scanlines, light aberration, bloom and a deep vignette.

Source

pub fn from_name(name: &str) -> Option<PostFx>

Preset by name: off, subtle, neon, warm-film (or warm_film), crt.

Source

pub fn from_index(index: u32) -> Option<PostFx>

Preset by index in from_name order.

Source

pub const fn bloom(self, intensity: f32, threshold: f32, radius: f32) -> PostFx

Source

pub const fn bloom_knee(self, knee: f32) -> PostFx

Source

pub const fn tonemap(self, tonemap: Tonemap) -> PostFx

Source

pub const fn exposure(self, exposure: f32) -> PostFx

Source

pub const fn contrast(self, contrast: f32) -> PostFx

Source

pub const fn saturation(self, saturation: f32) -> PostFx

Source

pub const fn lift_gamma_gain( self, lift: [f32; 3], gamma: [f32; 3], gain: [f32; 3], ) -> PostFx

Source

pub const fn tint(self, tint: Color) -> PostFx

Multiply highlights by a color (sets gain).

Source

pub const fn vignette(self, strength: f32, softness: f32) -> PostFx

Source

pub const fn grain(self, amount: f32) -> PostFx

Source

pub const fn aberration(self, amount: f32) -> PostFx

Source

pub const fn scanlines(self, amount: f32) -> PostFx

Source

pub const fn auto_hud(self, enabled: bool) -> PostFx

Source

pub fn sanitized(self) -> PostFx

Clamp every field to its documented range; non-finite values become neutral.

Source

pub fn is_off(&self) -> bool

True when the sanitized settings are the identity image transform, so hosts keep their direct path. Filmic is never the identity.

Trait Implementations§

Source§

impl Clone for PostFx

Source§

fn clone(&self) -> PostFx

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PostFx

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for PostFx

Source§

fn default() -> PostFx

Returns the “default value” for a type. Read more
Source§

impl PartialEq for PostFx

Source§

fn eq(&self, other: &PostFx) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PostFx

Source§

impl StructuralPartialEq for PostFx

Auto Trait Implementations§

§

impl Freeze for PostFx

§

impl RefUnwindSafe for PostFx

§

impl Send for PostFx

§

impl Sync for PostFx

§

impl Unpin for PostFx

§

impl UnwindSafe for PostFx

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.