pub enum VertexEffect {
Show 28 variants
Rotate {
speed: f32,
},
Wobble {
frequency: f32,
amplitude: f32,
},
Pulse {
frequency: f32,
amplitude: f32,
},
Wave {
direction: Vec3,
frequency: f32,
speed: f32,
amplitude: f32,
},
Jitter {
amplitude: f32,
},
StretchToVelocity {
max_stretch: f32,
},
ScaleByDistance {
center: Vec3,
min_scale: f32,
max_scale: f32,
max_distance: f32,
},
FadeByDistance {
near: f32,
far: f32,
},
BillboardCylindrical {
axis: Vec3,
},
BillboardFixed {
forward: Vec3,
up: Vec3,
},
FacePoint {
target: Vec3,
},
Orbit {
center: Vec3,
speed: f32,
radius: f32,
axis: Vec3,
},
Spiral {
center: Vec3,
speed: f32,
expansion: f32,
vertical_speed: f32,
},
Sway {
frequency: f32,
amplitude: f32,
axis: Vec3,
},
ScaleBySpeed {
min_scale: f32,
max_scale: f32,
max_speed: f32,
},
Squash {
axis: Vec3,
amount: f32,
},
Tumble {
speed: f32,
},
Attract {
target: Vec3,
strength: f32,
max_displacement: f32,
},
Repel {
source: Vec3,
strength: f32,
radius: f32,
},
Turbulence {
frequency: f32,
amplitude: f32,
speed: f32,
},
ScaleByAge {
start_scale: f32,
end_scale: f32,
lifetime: f32,
},
FadeByAge {
start_alpha: f32,
end_alpha: f32,
lifetime: f32,
},
Vortex {
center: Vec3,
speed: f32,
pull: f32,
radius: f32,
},
Bounce {
height: f32,
frequency: f32,
damping: f32,
},
Figure8 {
width: f32,
height: f32,
speed: f32,
ratio: f32,
},
Helix {
axis: Vec3,
radius: f32,
speed: f32,
progression: f32,
},
Flutter {
intensity: f32,
speed: f32,
},
Brownian {
intensity: f32,
speed: f32,
},
}Expand description
Vertex shader effects for particle rendering.
Pre-built, composable effects that modify particle vertex transformations.
Effects stack together and generate optimized WGSL code. Use these instead
of raw crate::Simulation::with_vertex_shader for common effects.
§Example
Simulation::<Ball>::new()
.with_vertex_effect(VertexEffect::Rotate { speed: 2.0 })
.with_vertex_effect(VertexEffect::Wobble {
frequency: 3.0,
amplitude: 0.05,
})
.with_vertex_effect(VertexEffect::Pulse {
frequency: 4.0,
amplitude: 0.3,
})
.run();Effects are applied in order and compose naturally.
Variants§
Rotate
Rotate particles around their facing axis.
Each particle spins at the specified speed, with a per-particle phase offset based on instance index for variety.
Wobble
Wobble particles with sinusoidal position offset.
Creates a gentle floating/swaying motion.
Fields
Pulse
Pulse particle size over time.
Particles grow and shrink rhythmically.
Fields
Wave
Wave effect coordinated across particles.
Creates a wave pattern that travels through the particle field.
Fields
Jitter
Random per-frame jitter/shake.
Adds noise-like motion to particles.
StretchToVelocity
Stretch particles in their velocity direction.
Requires velocity data passed to vertex shader. Note: This is a visual hint only - actual velocity stretching requires velocity in the vertex attributes.
ScaleByDistance
Scale particles based on distance from a point.
Particles closer to the point are larger.
Fields
FadeByDistance
Fade particles based on distance from camera/origin.
Modifies alpha based on distance for depth-based fading.
Fields
BillboardCylindrical
Cylindrical billboarding - rotate only around one axis.
Useful for grass, trees, flames - things that should stay upright but still face the camera horizontally.
BillboardFixed
Fixed orientation - disable billboarding entirely.
Particles maintain a fixed orientation in world space. Useful for debris, leaves, or when combined with Rotate for tumbling.
Fields
FacePoint
Orient particles to face a specific point.
All particles rotate to look at the target point.
Orbit
Orbit particles around a center point.
Creates circular motion around a specified axis.
Fields
Spiral
Spiral particles outward or inward.
Creates expanding or contracting spiral motion.
Fields
Sway
Sway particles like grass or trees.
Creates a natural swaying motion anchored at the base.
Fields
ScaleBySpeed
Scale particles based on their speed.
Faster particles appear larger or smaller.
Fields
Squash
Squash/flatten particles along an axis.
Creates a flattened appearance, good for impact effects.
Tumble
Tumble particles with random 3D rotation.
Creates chaotic spinning in all directions.
Attract
Attract particles toward a point.
Pulls particles closer to the target.
Fields
Repel
Repel particles away from a point.
Pushes particles away from the source.
Fields
Turbulence
Turbulence/noise-based displacement.
Creates organic, chaotic motion using noise.
Fields
ScaleByAge
Scale particles over their lifetime.
Particles grow or shrink as they age (approximated).
Fields
FadeByAge
Fade particles over their lifetime.
Particles become transparent as they age.
Fields
Vortex
Vortex/tornado effect - orbit with vertical pull.
Creates a whirlpool or tornado-like motion.
Fields
Bounce
Bounce particles with gravity-like motion.
Creates a bouncing ball effect.
Fields
Figure8
Figure-8 / Lissajous curve motion.
Creates infinity loops and complex orbital patterns.
Fields
Helix
Helix/corkscrew motion along an axis.
Creates DNA-like spiraling motion.
Fields
Flutter
Flutter - rapid small oscillations.
Creates leaf or butterfly-like trembling motion.
Brownian
Brownian motion - random walk.
Creates organic wandering motion that evolves over time.
Implementations§
Source§impl VertexEffect
impl VertexEffect
Sourcepub fn to_wgsl(&self) -> String
pub fn to_wgsl(&self) -> String
Generate WGSL code that modifies transformation variables.
Available variables to read/modify:
pos_offset: vec3<f32>- position offset (starts at 0)rotated_quad: vec2<f32>- quad coordinates (starts at quad_pos)size_mult: f32- size multiplier (starts at 1.0)color_mod: vec3<f32>- color modifier (starts at particle_color)
Also available (read-only):
particle_pos,particle_size,scaleuniforms.time,instance_index,vertex_index
Trait Implementations§
Source§impl Clone for VertexEffect
impl Clone for VertexEffect
Source§fn clone(&self) -> VertexEffect
fn clone(&self) -> VertexEffect
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for VertexEffect
impl RefUnwindSafe for VertexEffect
impl Send for VertexEffect
impl Sync for VertexEffect
impl Unpin for VertexEffect
impl UnwindSafe for VertexEffect
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
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.