Merge branch 'scott-c/fix-missing-firework-particles' into 'master'

fix missing firework/bomb particle rng & adjust firework colors

Closes #713

See merge request veloren/veloren!1351
This commit is contained in:
Joshua Barretto 2020-09-01 14:01:13 +00:00
commit d8da10f1ff
3 changed files with 87 additions and 67 deletions

View File

@ -91,6 +91,15 @@ mat4 spin_in_axis(vec3 axis, float angle)
0, 0, 0, 1);
}
mat4 identity() {
return mat4(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
}
void main() {
float rand0 = hash(vec4(inst_entropy + 0));
float rand1 = hash(vec4(inst_entropy + 1));
@ -108,7 +117,7 @@ void main() {
if (inst_mode == SMOKE) {
attr = Attr(
linear_motion(
vec3(0.0, 0.0, 0.0),
vec3(0),
vec3(rand2 * 0.02, rand3 * 0.02, 1.0 + rand4 * 0.1)
),
linear_scale(0.5),
@ -148,52 +157,52 @@ void main() {
} else if (inst_mode == FIREWORK_BLUE) {
attr = Attr(
linear_motion(
vec3(0.0, 1.0, 1.0),
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
),
3.0 + rand0,
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
spin_in_axis(vec3(1,0,0),0)
vec4(0.15, 0.4, 1, 1),
identity()
);
} else if (inst_mode == FIREWORK_GREEN) {
attr = Attr(
linear_motion(
vec3(0.0, 1.0, 0.0),
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
),
3.0 + rand0,
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
spin_in_axis(vec3(1,0,0),0)
vec4(0, 1, 0, 1),
identity()
);
} else if (inst_mode == FIREWORK_PURPLE) {
attr = Attr(
linear_motion(
vec3(1.0, 0.0, 1.0),
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
),
3.0 + rand0,
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
spin_in_axis(vec3(1,0,0),0)
vec4(0.7, 0.0, 1.0, 1.0),
identity()
);
} else if (inst_mode == FIREWORK_RED) {
attr = Attr(
linear_motion(
vec3(1.0, 0.0, 0.0),
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
),
3.0 + rand0,
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
spin_in_axis(vec3(1,0,0),0)
vec4(1, 0, 0, 1),
identity()
);
} else if (inst_mode == FIREWORK_YELLOW) {
attr = Attr(
linear_motion(
vec3(1.0, 1.0, 0.0),
vec3(rand4, rand5, rand6) * 40.0 + grav_vel(earth_gravity)
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
),
3.0 + rand0,
vec4(vec3(0.6 + rand7 * 0.4), 0.3),
spin_in_axis(vec3(1,0,0),0)
vec4(1, 1, 0, 1),
identity()
);
} else if (inst_mode == LEAF) {
attr = Attr(

View File

@ -391,9 +391,9 @@ impl Scene {
light: Light::new(
*pos,
match reagent {
Some(Reagent::Blue) => Rgb::new(0.0, 0.0, 1.0),
Some(Reagent::Blue) => Rgb::new(0.15, 0.4, 1.0),
Some(Reagent::Green) => Rgb::new(0.0, 1.0, 0.0),
Some(Reagent::Purple) => Rgb::new(1.0, 0.0, 1.0),
Some(Reagent::Purple) => Rgb::new(0.7, 0.0, 1.0),
Some(Reagent::Red) => Rgb::new(1.0, 0.0, 0.0),
Some(Reagent::Yellow) => Rgb::new(1.0, 1.0, 0.0),
None => Rgb::new(1.0, 0.5, 0.0),

View File

@ -57,8 +57,9 @@ impl ParticleMgr {
power,
reagent,
} => {
self.particles.resize(
self.particles.len() + 150,
self.particles.resize_with(
self.particles.len() + if reagent.is_some() { 300 } else { 150 },
|| {
Particle::new(
Duration::from_millis(if reagent.is_some() { 1000 } else { 250 }),
time,
@ -71,17 +72,21 @@ impl ParticleMgr {
None => ParticleMode::Shrapnel,
},
*pos,
),
)
},
);
self.particles.resize_with(self.particles.len() + 200, || {
self.particles.resize_with(
self.particles.len() + if reagent.is_some() { 100 } else { 200 },
|| {
Particle::new(
Duration::from_secs(4),
time,
ParticleMode::CampfireSmoke,
*pos + Vec2::<f32>::zero().map(|_| rng.gen_range(-1.0, 1.0) * power),
)
});
},
);
},
Outcome::ProjectileShot { .. } => {},
}
@ -185,25 +190,29 @@ impl ParticleMgr {
let time = scene_data.state.get_time();
// fire
self.particles.resize(
self.particles.resize_with(
self.particles.len() + usize::from(self.scheduler.heartbeats(Duration::from_millis(3))),
|| {
Particle::new(
Duration::from_millis(250),
time,
ParticleMode::CampfireFire,
pos.0,
),
)
},
);
// smoke
self.particles.resize(
self.particles.resize_with(
self.particles.len() + usize::from(self.scheduler.heartbeats(Duration::from_millis(5))),
|| {
Particle::new(
Duration::from_secs(2),
time,
ParticleMode::CampfireSmoke,
pos.0,
),
)
},
);
}
@ -241,15 +250,17 @@ impl ParticleMgr {
.join()
{
if let CharacterState::Boost(_) = character_state {
self.particles.resize(
self.particles.resize_with(
self.particles.len()
+ usize::from(self.scheduler.heartbeats(Duration::from_millis(10))),
|| {
Particle::new(
Duration::from_secs(15),
time,
ParticleMode::CampfireSmoke,
pos.0,
),
)
},
);
}
}