pub trait PostEffect:
Send
+ Sync
+ 'static {
// Required method
fn apply(&self, queue: &mut RenderQueue, window_w: f32, window_h: f32);
}Expand description
trait for a custom post-processing effect applied each frame after the main render.
implement this and push instances onto PostProcessStack to draw
screen-space overlays. uses layers::POST_PROCESS coordinates: top-left is
(0, 0), bottom-right is (window_w, window_h).
§example
ⓘ
use lunar::prelude::*;
struct Vignette;
impl PostEffect for Vignette {
fn apply(&self, queue: &mut RenderQueue, w: f32, h: f32) {
let border = 40.0;
let color = Color::rgba(0.0, 0.0, 0.0, 0.35);
queue.draw_screen_rect(Vec2::ZERO, Vec2::new(w, border), color);
queue.draw_screen_rect(Vec2::new(0.0, h - border), Vec2::new(w, border), color);
}
}Required Methods§
Sourcefn apply(&self, queue: &mut RenderQueue, window_w: f32, window_h: f32)
fn apply(&self, queue: &mut RenderQueue, window_w: f32, window_h: f32)
draw the effect’s commands into the queue.
window_w and window_h are the current surface dimensions in pixels.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".