VertexEffect

Enum VertexEffect 

Source
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.

Fields

§speed: f32

Rotation speed in radians per second.

§

Wobble

Wobble particles with sinusoidal position offset.

Creates a gentle floating/swaying motion.

Fields

§frequency: f32

Oscillation frequency (higher = faster wobble).

§amplitude: f32

Maximum offset distance.

§

Pulse

Pulse particle size over time.

Particles grow and shrink rhythmically.

Fields

§frequency: f32

Pulse frequency (higher = faster pulsing).

§amplitude: f32

Pulse amplitude (0.3 = +/- 30% size variation).

§

Wave

Wave effect coordinated across particles.

Creates a wave pattern that travels through the particle field.

Fields

§direction: Vec3

Wave direction (normalized).

§frequency: f32

Wave frequency (spatial).

§speed: f32

Wave speed (temporal).

§amplitude: f32

Wave amplitude (offset distance).

§

Jitter

Random per-frame jitter/shake.

Adds noise-like motion to particles.

Fields

§amplitude: f32

Maximum jitter offset.

§

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.

Fields

§max_stretch: f32

Maximum stretch multiplier.

§

ScaleByDistance

Scale particles based on distance from a point.

Particles closer to the point are larger.

Fields

§center: Vec3

Center point.

§min_scale: f32

Scale at center (closest).

§max_scale: f32

Scale at max_distance (farthest).

§max_distance: f32

Distance at which max_scale is reached.

§

FadeByDistance

Fade particles based on distance from camera/origin.

Modifies alpha based on distance for depth-based fading.

Fields

§near: f32

Distance at which particles are fully visible.

§far: f32

Distance at which particles are fully transparent.

§

BillboardCylindrical

Cylindrical billboarding - rotate only around one axis.

Useful for grass, trees, flames - things that should stay upright but still face the camera horizontally.

Fields

§axis: Vec3

The axis to stay fixed (typically Y for upright sprites).

§

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

§forward: Vec3

Forward direction of the quad in world space.

§up: Vec3

Up direction of the quad in world space.

§

FacePoint

Orient particles to face a specific point.

All particles rotate to look at the target point.

Fields

§target: Vec3

The point all particles should face toward.

§

Orbit

Orbit particles around a center point.

Creates circular motion around a specified axis.

Fields

§center: Vec3

Center point of the orbit.

§speed: f32

Orbit speed in radians per second.

§radius: f32

Orbit radius.

§axis: Vec3

Axis of rotation (normalized).

§

Spiral

Spiral particles outward or inward.

Creates expanding or contracting spiral motion.

Fields

§center: Vec3

Center point of the spiral.

§speed: f32

Rotation speed in radians per second.

§expansion: f32

Expansion rate (positive = outward, negative = inward).

§vertical_speed: f32

Vertical speed (for 3D spirals).

§

Sway

Sway particles like grass or trees.

Creates a natural swaying motion anchored at the base.

Fields

§frequency: f32

Sway frequency.

§amplitude: f32

Maximum sway amplitude.

§axis: Vec3

Sway axis (typically horizontal).

§

ScaleBySpeed

Scale particles based on their speed.

Faster particles appear larger or smaller.

Fields

§min_scale: f32

Scale at zero speed.

§max_scale: f32

Scale at max speed.

§max_speed: f32

Speed at which max_scale is reached.

§

Squash

Squash/flatten particles along an axis.

Creates a flattened appearance, good for impact effects.

Fields

§axis: Vec3

Axis to squash along.

§amount: f32

Squash amount (0 = flat, 1 = normal).

§

Tumble

Tumble particles with random 3D rotation.

Creates chaotic spinning in all directions.

Fields

§speed: f32

Rotation speed multiplier.

§

Attract

Attract particles toward a point.

Pulls particles closer to the target.

Fields

§target: Vec3

Attraction target point.

§strength: f32

Attraction strength.

§max_displacement: f32

Maximum displacement.

§

Repel

Repel particles away from a point.

Pushes particles away from the source.

Fields

§source: Vec3

Repulsion source point.

§strength: f32

Repulsion strength.

§radius: f32

Effect radius (no effect beyond this).

§

Turbulence

Turbulence/noise-based displacement.

Creates organic, chaotic motion using noise.

Fields

§frequency: f32

Noise frequency (higher = more detail).

§amplitude: f32

Displacement amplitude.

§speed: f32

Animation speed.

§

ScaleByAge

Scale particles over their lifetime.

Particles grow or shrink as they age (approximated).

Fields

§start_scale: f32

Scale at birth.

§end_scale: f32

Scale at end of life.

§lifetime: f32

Lifetime duration in seconds.

§

FadeByAge

Fade particles over their lifetime.

Particles become transparent as they age.

Fields

§start_alpha: f32

Alpha at birth.

§end_alpha: f32

Alpha at end of life.

§lifetime: f32

Lifetime duration in seconds.

§

Vortex

Vortex/tornado effect - orbit with vertical pull.

Creates a whirlpool or tornado-like motion.

Fields

§center: Vec3

Center point of the vortex.

§speed: f32

Rotation speed in radians per second.

§pull: f32

Vertical pull strength (positive = up, negative = down).

§radius: f32

Vortex radius influence.

§

Bounce

Bounce particles with gravity-like motion.

Creates a bouncing ball effect.

Fields

§height: f32

Bounce height.

§frequency: f32

Bounce frequency (bounces per second).

§damping: f32

Energy loss per bounce (0 = no loss, 1 = full loss).

§

Figure8

Figure-8 / Lissajous curve motion.

Creates infinity loops and complex orbital patterns.

Fields

§width: f32

Horizontal amplitude.

§height: f32

Vertical amplitude.

§speed: f32

Animation speed.

§ratio: f32

Frequency ratio (2 = figure-8, other values = Lissajous).

§

Helix

Helix/corkscrew motion along an axis.

Creates DNA-like spiraling motion.

Fields

§axis: Vec3

Axis of helix progression.

§radius: f32

Helix radius.

§speed: f32

Rotation speed.

§progression: f32

Forward movement speed along axis.

§

Flutter

Flutter - rapid small oscillations.

Creates leaf or butterfly-like trembling motion.

Fields

§intensity: f32

Flutter intensity.

§speed: f32

Flutter speed (higher = more rapid).

§

Brownian

Brownian motion - random walk.

Creates organic wandering motion that evolves over time.

Fields

§intensity: f32

Movement intensity.

§speed: f32

How fast the random direction changes.

Implementations§

Source§

impl VertexEffect

Source

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, scale
  • uniforms.time, instance_index, vertex_index

Trait Implementations§

Source§

impl Clone for VertexEffect

Source§

fn clone(&self) -> VertexEffect

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 VertexEffect

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,