Skip to content

Commit

Permalink
Make effect more distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
NiseVoid committed May 19, 2024
1 parent 7c6c307 commit 0f269a3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions examples/instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut my_effect: ResMut<InstanceManager>,
loader: Res<AssetServer>,
) {
info!("Usage: Press the SPACE key to spawn more instances, and the DELETE key to remove an existing instance.");

Expand Down Expand Up @@ -272,10 +273,11 @@ fn setup(
gradient.add_key(0.0, Vec4::new(1., 0., 0., 0.));
gradient.add_key(0.1, Vec4::new(1., 0., 0., 1.));
gradient.add_key(1.0, Vec4::new(1., 0., 0., 0.));
let texture = loader.load("circle.png");

let writer = ExprWriter::new();

let lifetime = writer.lit(2.).expr();
let lifetime = writer.lit(5.).expr();
let init_lifetime = SetAttributeModifier::new(Attribute::LIFETIME, lifetime);

let init_pos = SetPositionSphereModifier {
Expand All @@ -290,12 +292,21 @@ fn setup(
speed: writer.lit(4.).expr(),
};

let radial_accel =
RadialAccelModifier::new(writer.lit(Vec3::ZERO).expr(), writer.lit(-3).expr());

let alt_effect = effects.add(
EffectAsset::new(vec![512], Spawner::rate(256.0.into()), writer.finish())
EffectAsset::new(vec![512], Spawner::rate(102.0.into()), writer.finish())
.with_simulation_space(SimulationSpace::Local)
.with_name("alternate instancing")
.init(init_pos)
.init(init_vel)
.init(init_lifetime)
.update(radial_accel)
.render(ParticleTextureModifier {
texture,
..default()
})
.render(ColorOverLifetimeModifier { gradient }),
);

Expand Down

0 comments on commit 0f269a3

Please sign in to comment.