pub struct DistortionMap {
pub width: u32,
pub height: u32,
/* private fields */
}Expand description
A CPU-side distortion map — an array of 2D UV offsets, one per pixel.
The GPU reads this as a 2D texture (RG32F) and uses it to offset UV lookups when sampling the scene texture.
Fields§
§width: u32§height: u32Implementations§
Source§impl DistortionMap
impl DistortionMap
pub fn new(width: u32, height: u32) -> Self
pub fn clear(&mut self)
pub fn set(&mut self, x: u32, y: u32, offset: Vec2)
pub fn get(&self, x: u32, y: u32) -> Vec2
pub fn add(&mut self, x: u32, y: u32, offset: Vec2)
Sourcepub fn as_f32_slice(&self) -> Vec<f32>
pub fn as_f32_slice(&self) -> Vec<f32>
Raw f32 slice for GPU upload (RGBA32F, packed as [r_offset, g_offset, 0, 0] per pixel).
Sourcepub fn add_gravity_lens(
&mut self,
center_uv: Vec2,
strength: f32,
radius_uv: f32,
)
pub fn add_gravity_lens( &mut self, center_uv: Vec2, strength: f32, radius_uv: f32, )
Write a radial gravity lens distortion around a screen-space center.
center_uv in [0, 1], strength is UV units of max displacement,
radius_uv is the falloff radius in UV units.
Sourcepub fn add_heat_shimmer(
&mut self,
region_min: Vec2,
region_max: Vec2,
strength: f32,
time: f32,
)
pub fn add_heat_shimmer( &mut self, region_min: Vec2, region_max: Vec2, strength: f32, time: f32, )
Write a heat shimmer distortion (Perlin noise based, animated by time).
Sourcepub fn clamp_offsets(&mut self, max_magnitude: f32)
pub fn clamp_offsets(&mut self, max_magnitude: f32)
Clamp all offsets to max_magnitude UV units.
pub fn pixel_count(&self) -> usize
Auto Trait Implementations§
impl Freeze for DistortionMap
impl RefUnwindSafe for DistortionMap
impl Send for DistortionMap
impl Sync for DistortionMap
impl Unpin for DistortionMap
impl UnsafeUnpin for DistortionMap
impl UnwindSafe for DistortionMap
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.