pub struct ScreenFx {Show 15 fields
pub lights: Vec<ScreenLight>,
pub ambient: Vec3,
pub shadow_density: f32,
pub shockwaves: Vec<Shockwave>,
pub reflection: Option<Reflection>,
pub haze: f32,
pub auto_shafts: bool,
pub flash: Vec3,
pub flash_decay: f32,
pub shaft_origin: Option<Vec2>,
pub shaft_strength: f32,
pub shaft_target: f32,
pub shaft_ease: f32,
pub shaft_tint: Vec3,
pub time: f32,
}Expand description
Transient screen effects. Lives on the engine as engine.fx.
Fields§
§lights: Vec<ScreenLight>This frame’s lights. Cleared by the engine after every render, so a game pushes the lights it wants every frame.
ambient: Vec3The light every pixel gets with no light on it. White is unlit: the scene as drawn. Anything darker turns the light map on.
shadow_density: f32How much light one fully covered shadow sample removes. Higher is harder-edged, denser shadow.
shockwaves: Vec<Shockwave>§reflection: Option<Reflection>A floor reflection, if the scene has a floor worth reflecting in.
Set every frame it should show; cleared with clear_reflection.
haze: f32Heat shimmer over the whole frame, 0.0 to about 1.0. Stronger toward the bottom of the frame, where hot air rises from.
auto_shafts: boolLet the renderer pick the light-shaft source itself, from whatever is brightest in the bloom, whenever no explicit source is set. Costs one tiny read-back per frame and is a frame late, which no one can see.
flash: Vec3Colour added to the whole frame before the tonemap, already scaled by its strength. Decays toward black.
flash_decay: f32Fraction of the flash that survives each second.
shaft_origin: Option<Vec2>Where light shafts stream from, in screen pixels, if anywhere.
shaft_strength: f32How strong the shafts are right now. Eases toward shaft_target.
shaft_target: f32Where the shaft strength is heading.
shaft_ease: f32How quickly the shafts ease toward the target, per second.
shaft_tint: Vec3A colour cast for the shafts. White lets the light’s own colour through.
time: f32Seconds accumulated, for anything that wants a clock.
Implementations§
Source§impl ScreenFx
impl ScreenFx
pub fn new() -> Self
Sourcepub fn shockwave(&mut self, x: f32, y: f32, strength: f32)
pub fn shockwave(&mut self, x: f32, y: f32, strength: f32)
Fire a shockwave with sensible defaults for a hit: a ring that crosses a 1280-wide frame in about half a second.
strength is the peak displacement in pixels; 6 to 10 reads as a
blow, 20 or more as an explosion.
Sourcepub fn shockwave_with(&mut self, wave: Shockwave)
pub fn shockwave_with(&mut self, wave: Shockwave)
Fire a fully specified shockwave. If the cap is reached the oldest one is dropped, so the newest blow always shows.
Sourcepub fn flash(&mut self, color: Vec3, strength: f32)
pub fn flash(&mut self, color: Vec3, strength: f32)
Flash the frame. strength of 1.0 is a full-colour hit before the
tonemap rolls it off; 0.2 is a noticeable pulse.
Sourcepub fn light_shaft_at(&mut self, x: f32, y: f32, strength: f32)
pub fn light_shaft_at(&mut self, x: f32, y: f32, strength: f32)
Stream light shafts from a screen point at the given strength. Call every frame the source is on screen; the strength eases in and out.
Sourcepub fn clear_light_shaft(&mut self)
pub fn clear_light_shaft(&mut self)
Let the shafts fade out. The origin is kept until they are gone so the fade happens in place.
Sourcepub fn light(
&mut self,
x: f32,
y: f32,
radius: f32,
color: Vec3,
intensity: f32,
)
pub fn light( &mut self, x: f32, y: f32, radius: f32, color: Vec3, intensity: f32, )
Add a shadow-casting light for this frame.
Sourcepub fn light_unshadowed(
&mut self,
x: f32,
y: f32,
radius: f32,
color: Vec3,
intensity: f32,
)
pub fn light_unshadowed( &mut self, x: f32, y: f32, radius: f32, color: Vec3, intensity: f32, )
Add a light nothing shadows, for a glow rather than a lamp.
pub fn push_light(&mut self, light: ScreenLight)
Sourcepub fn lighting_active(&self) -> bool
pub fn lighting_active(&self) -> bool
Whether the light map has anything to do this frame.
Sourcepub fn pack_lights(
&self,
screen_w: f32,
screen_h: f32,
) -> (Vec<f32>, Vec<f32>, usize)
pub fn pack_lights( &self, screen_w: f32, screen_h: f32, ) -> (Vec<f32>, Vec<f32>, usize)
Pack the lights for the shader: (u, v, radius_px, shadows) and
(r, g, b, intensity), v flipped to texture space.
Sourcepub fn reflect_at(&mut self, y: f32, strength: f32, fade: f32)
pub fn reflect_at(&mut self, y: f32, strength: f32, fade: f32)
Reflect the picture about the line y pixels from the top, for
fade pixels below it, at the given strength. A still, lightly
blurred mirror; set the fields on Reflection for a wet one.
pub fn clear_reflection(&mut self)
Sourcepub fn pack_reflection(&self, screen_w: f32, screen_h: f32) -> ([f32; 4], f32)
pub fn pack_reflection(&self, screen_w: f32, screen_h: f32) -> ([f32; 4], f32)
The reflection for the shader: (line_v, strength, fade_v, ripple_px)
and the blur, in texture space with v = 0 at the bottom.
Sourcepub fn is_idle(&self) -> bool
pub fn is_idle(&self) -> bool
Whether anything at all is active, so the renderer can skip uploads.
Sourcepub fn pack_shockwaves(
&self,
screen_w: f32,
screen_h: f32,
) -> ([[f32; 4]; 12], [f32; 12], usize)
pub fn pack_shockwaves( &self, screen_w: f32, screen_h: f32, ) -> ([[f32; 4]; 12], [f32; 12], usize)
Pack the shockwaves for the composite shader.
Returns (data, strengths, count). Each data entry is
(u, v, radius_px, width_px) with u, v in texture space, which has
v = 0 at the bottom, so y is flipped here from the UI’s y-down.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScreenFx
impl RefUnwindSafe for ScreenFx
impl Send for ScreenFx
impl Sync for ScreenFx
impl Unpin for ScreenFx
impl UnsafeUnpin for ScreenFx
impl UnwindSafe for ScreenFx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.