From df70976ff5666fcbc7e4523fd70c1cf78db1f1d5 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 Feb 2021 01:05:14 -0500 Subject: [PATCH] Fixed particles. --- .../common/abilities/staff/flamethrower.ron | 4 +-- assets/voxygen/shaders/particle-vert.glsl | 34 ++++++++++++------- voxygen/src/render/pipelines/particle.rs | 1 + voxygen/src/scene/particle.rs | 33 ++++++++---------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/assets/common/abilities/staff/flamethrower.ron b/assets/common/abilities/staff/flamethrower.ron index 9c94bc65c7..7bb592a9fb 100644 --- a/assets/common/abilities/staff/flamethrower.ron +++ b/assets/common/abilities/staff/flamethrower.ron @@ -1,11 +1,11 @@ BasicBeam( buildup_duration: 0.25, recover_duration: 0.25, - beam_duration: 0.5, + beam_duration: 1.0, base_hps: 0, base_dps: 150, tick_rate: 3.0, - range: 15.0, + range: 20.0, max_angle: 10.0, lifesteal_eff: 0.0, energy_regen: 0, diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index 70389f8599..3bef025d4d 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -57,6 +57,7 @@ const int FLAMETHROWER = 15; const int FIRE_SHOCKWAVE = 16; const int FIRE_BOWL = 17; const int SNOW = 18; +const int EXPLOSION = 19; // meters per second squared (acceleration) const float earth_gravity = 9.807; @@ -132,14 +133,14 @@ vec3 perp_axis2(vec3 axis1, vec3 axis2) { return normalize(vec3(axis1.y * axis2.z - axis1.z * axis2.y, axis1.z * axis2.x - axis1.x * axis2.z, axis1.x * axis2.y - axis1.y * axis2.x)); } -vec3 spiral_motion(vec3 line, float radius, float time_function) { +vec3 spiral_motion(vec3 line, float radius, float time_function, float frequency, float offset) { vec3 axis2 = perp_axis1(line); vec3 axis3 = perp_axis2(line, axis2); - return vec3( - radius * cos(time_function) * axis2.x + radius * sin(time_function) * axis3.x, - radius * cos(time_function) * axis2.y + radius * sin(time_function) * axis3.y, - radius * cos(time_function) * axis2.z + radius * sin(time_function) * axis3.z); + return line * time_function + vec3( + radius * cos(frequency * time_function - offset) * axis2.x + radius * sin(frequency * time_function - offset) * axis3.x, + radius * cos(frequency * time_function - offset) * axis2.y + radius * sin(frequency * time_function - offset) * axis3.y, + radius * cos(frequency * time_function - offset) * axis2.z + radius * sin(frequency * time_function - offset) * axis3.z); } void main() { @@ -321,16 +322,16 @@ void main() { } else if (inst_mode == HEALING_BEAM) { f_reflect = 0.0; attr = Attr( - spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan), + spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan, 10.0, inst_time), vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))), - vec4(vec3(0.4, 2.7 + 0.4 * sin(tick.x * 8 - lifetime * 3 + 4), 0.5 + 0.6 * sin(tick.x * 7)), start_end(1.0, 0.0) /*0.3*/), + vec4(vec3(0.4, 1.6 + 0.3 * sin(tick.x * 10 - lifetime * 3 + 4), 1.0 + 0.15 * sin(tick.x * 5 - lifetime * 5)), start_end(1.0, 0.0) /*0.3*/), spin_in_axis(inst_dir, tick.z) ); } else if (inst_mode == ENERGY_NATURE) { f_reflect = 0.0; attr = Attr( inst_dir * slow_end(0.03) + spiral_motion(vec3(rand1, rand2, rand3), - 0.2 * (rand4 + 1.3) * slow_end(0.02), percent() * 3 * (rand4 + 4.0) + rand0), + 0.2 * (rand4 + 1.3) * slow_end(0.02), percent() * 3 * (rand4 + 4.0) + rand0, 1.0, 0.0), vec3(1.0), vec4(vec3(0, 2.5, 1.5 + rand7 * 0.7), start_end(1.0, 0.0)), spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3) @@ -338,8 +339,15 @@ void main() { } else if (inst_mode == FLAMETHROWER) { f_reflect = 0.0; // Fire doesn't reflect light, it emits it attr = Attr( - inst_dir * ((rand0+1.0)/2 + 0.5) * slow_end(0.2) + /*0.4 * vec3(rand0, - rand1, rand2) * slow_end(0.1)*/ + 0.1 * grav_vel(earth_gravity), + (inst_dir * slow_end(1.5)) + vec3(rand0, rand1, rand2) * (lifetime * 5 + 0.25), + vec3((2.5 * (1 - slow_start(0.3)))), + vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)), + spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9) + ); + } else if (inst_mode == EXPLOSION) { + f_reflect = 0.0; // Fire doesn't reflect light, it emits it + attr = Attr( + inst_dir * ((rand0+1.0)/2 + 0.5) * slow_end(0.2) + 0.1 * grav_vel(earth_gravity), vec3((3 * (1 - slow_start(0.1)))), vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)), spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9) @@ -347,9 +355,9 @@ void main() { } else if (inst_mode == FIRE_SHOCKWAVE) { f_reflect = 0.0; // Fire doesn't reflect light, it emits it attr = Attr( - vec3(rand0, rand1, lifetime * 1 + rand2), - vec3(1.6 + rand3 * 1.5 + 10 * (lifetime + inst_lifespan)), - vec4(3, 1.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0.2, start_end(1.0, 0.0) /*0.8 - 3.5 * inst_lifespan*/), + vec3(rand0, rand1, lifetime * 10 + rand2), + vec3((5 * (1 - slow_start(0.5)))), + vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)), spin_in_axis(vec3(rand3, rand4, rand5), rand6) ); } else { diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index 09e1218db1..c5db9acfda 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -115,6 +115,7 @@ pub enum ParticleMode { FireShockwave = 16, FireBowl = 17, Snow = 18, + Explosion = 19, } impl ParticleMode { diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 1ca900113f..7389fa66f4 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -64,10 +64,10 @@ impl ParticleMgr { if *is_attack { if *power < 0.0 { self.particles.resize_with( - self.particles.len() + (200.0 * power.abs()) as usize, + self.particles.len() + (60.0 * power.abs()) as usize, || { Particle::new_directed( - Duration::from_secs_f32(rng.gen_range(1.0..8.0)), + Duration::from_secs_f32(rng.gen_range(0.2..3.0)), time, ParticleMode::EnergyNature, *pos, @@ -80,12 +80,12 @@ impl ParticleMgr { ); } else { self.particles.resize_with( - self.particles.len() + (200.0 * power.abs()) as usize, + self.particles.len() + (75.0 * power.abs()) as usize, || { Particle::new_directed( - Duration::from_secs(2), + Duration::from_millis(500), time, - ParticleMode::FlameThrower, + ParticleMode::Explosion, *pos, *pos + Vec3::::zero() .map(|_| rng.gen_range(-1.0..1.0)) @@ -642,7 +642,7 @@ impl ParticleMgr { let theta = ori_vec.y.atan2(ori_vec.x); let dtheta = radians / distance; - let heartbeats = self.scheduler.heartbeats(Duration::from_millis(1)); + let heartbeats = self.scheduler.heartbeats(Duration::from_millis(5)); for heartbeat in 0..heartbeats { if shockwave.properties.requires_ground { @@ -667,28 +667,25 @@ impl ParticleMgr { let position_snapped = ((position / scale).floor() + 0.5) * scale; - self.particles.push(Particle::new_directed( - Duration::from_secs(2), + self.particles.push(Particle::new( + Duration::from_millis(250), time, ParticleMode::GroundShockwave, position_snapped, - Vec3::new(0.0, 0.0, 10.0) + position_snapped, )); } } else { - for d in 0..8 * distance as i32 { + for d in 0..3 * distance as i32 { let arc_position = theta - radians / 2.0 + dtheta * d as f32 / 3.0; - let diff = - distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0); - let position = pos.0 + diff; + let position = pos.0 + + distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0); - self.particles.push(Particle::new_directed( - Duration::from_millis(500), + self.particles.push(Particle::new( + Duration::from_secs_f32((distance + 10.0) / 50.0), time, - ParticleMode::FlameThrower, - pos.0 + diff * 0.9, - Vec3::new(0.0, 0.0, 2.0) + position, + ParticleMode::FireShockwave, + position, )); } }