From 4bbc340f526ba09ab1b77d98702d01bd53da87ca Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 14 Oct 2019 10:48:40 +0100 Subject: [PATCH 1/2] Faster meshing, better dusk --- assets/voxygen/shaders/include/sky.glsl | 4 ++-- voxygen/src/mesh/terrain.rs | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 82398a05c5..2c4ca268be 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -11,7 +11,7 @@ const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0); const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20); const vec3 SKY_DUSK_MID = vec3(0.35, 0.1, 0.15); const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.13); -const vec3 DUSK_LIGHT = vec3(3.0, 1.0, 0.3); +const vec3 DUSK_LIGHT = vec3(3.0, 1.5, 0.3); const vec3 SUN_HALO_DUSK = vec3(0.6, 0.1, 0.0); const vec3 SKY_NIGHT_TOP = vec3(0.001, 0.001, 0.0025); @@ -56,7 +56,7 @@ void get_sun_diffuse(vec3 norm, float time_of_day, out vec3 light, out vec3 diff vec3 sun_chroma = sun_color * sun_light; light = sun_chroma + PERSISTENT_AMBIANCE; - diffuse_light = sun_chroma * mix(1.0, dot(-norm, sun_dir) * 0.5 + 0.5, diffusion) + PERSISTENT_AMBIANCE; + diffuse_light = sun_chroma * mix(1.0, max(dot(-norm, sun_dir) * 0.6 + 0.4, 0.0), diffusion) + PERSISTENT_AMBIANCE; ambient_light = vec3(SUN_AMBIANCE * sun_light); } diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index b40ed26035..fec89fb225 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -44,7 +44,7 @@ fn calc_light + ReadVol + Debug>( let mut vol_cached = vol.cached(); let mut voids = HashMap::new(); - let mut rays = vec![outer.size().d; outer.size().product() as usize]; + let mut rays = vec![(outer.size().d, 0); outer.size().product() as usize]; for x in 0..outer.size().w { for y in 0..outer.size().h { let mut outside = true; @@ -55,9 +55,12 @@ fn calc_light + ReadVol + Debug>( .copied() .unwrap_or(Block::empty()); - if !block.is_air() && outside { - rays[(outer.size().w * y + x) as usize] = z; - outside = false; + if !block.is_air() { + if outside { + rays[(outer.size().w * y + x) as usize].0 = z; + outside = false; + } + rays[(outer.size().w * y + x) as usize].1 = z; } if (block.is_air() || block.is_fluid()) && !outside { @@ -74,6 +77,7 @@ fn calc_light + ReadVol + Debug>( if pos.z > *rays .get(((outer.size().w * col.y) + col.x) as usize) + .map(|(ray, _)| ray) .unwrap_or(&0) { *l = Some(sunlight - 1); @@ -85,6 +89,7 @@ fn calc_light + ReadVol + Debug>( if pos.z >= *rays .get(((outer.size().w * pos.y) + pos.x) as usize) + .map(|(ray, _)| ray) .unwrap_or(&0) { *l = Some(sunlight - 1); @@ -114,7 +119,15 @@ fn calc_light + ReadVol + Debug>( move |wpos| { let pos = wpos - outer.min; rays.get(((outer.size().w * pos.y) + pos.x) as usize) - .and_then(|ray| if pos.z > *ray { Some(1.0) } else { None }) + .and_then(|(ray, deep)| { + if pos.z > *ray { + Some(1.0) + } else if pos.z < *deep { + Some(0.0) + } else { + None + } + }) .or_else(|| { if let Some(Some(l)) = voids.get(&pos) { Some(*l as f32 / sunlight as f32) From 707b79f2c89af98390ff71c1e199a7c7ff60bead Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 14 Oct 2019 11:22:48 +0100 Subject: [PATCH 2/2] Smoother movement, Space for climbing --- common/src/sys/movement.rs | 4 ++-- common/src/sys/phys.rs | 2 +- voxygen/src/menu/char_selection/scene.rs | 1 + voxygen/src/scene/figure/mod.rs | 9 +++++++-- voxygen/src/settings.rs | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 393de342c8..a6cc9533e5 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -13,7 +13,7 @@ use vek::*; pub const ROLL_DURATION: Duration = Duration::from_millis(600); -const HUMANOID_ACCEL: f32 = 70.0; +const HUMANOID_ACCEL: f32 = 50.0; const HUMANOID_SPEED: f32 = 120.0; const HUMANOID_AIR_ACCEL: f32 = 10.0; const HUMANOID_AIR_SPEED: f32 = 100.0; @@ -163,7 +163,7 @@ impl<'a> System<'a> for Sys { ori.0 = vek::ops::Slerp::slerp( ori.0, ori_dir.into(), - if physics.on_ground { 12.0 } else { 2.0 } * dt.0, + if physics.on_ground { 9.0 } else { 2.0 } * dt.0, ); } diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 0d5f656ffa..68a24a5e0c 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -18,7 +18,7 @@ const BOUYANCY: f32 = 0.0; // amount an object will slow down within 1/60th of a second. Eg. if the frction // is 0.01, and the speed is 1.0, then after 1/60th of a second the speed will // be 0.99. after 1 second the speed will be 0.54, which is 0.99 ^ 60. -const FRIC_GROUND: f32 = 0.125; +const FRIC_GROUND: f32 = 0.08; const FRIC_AIR: f32 = 0.0125; const FRIC_FLUID: f32 = 0.2; diff --git a/voxygen/src/menu/char_selection/scene.rs b/voxygen/src/menu/char_selection/scene.rs index 08a4610619..4b2c99bfcc 100644 --- a/voxygen/src/menu/char_selection/scene.rs +++ b/voxygen/src/menu/char_selection/scene.rs @@ -161,6 +161,7 @@ impl Scene { self.figure_state.update( renderer, Vec3::zero(), + Vec3::zero(), Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0), 1.0, Rgba::broadcast(1.0), diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 72cceca089..d5280817c8 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -257,6 +257,7 @@ impl FigureMgr { state.update( renderer, pos.0, + vel.0, ori.0, scale, col, @@ -311,6 +312,7 @@ impl FigureMgr { state.update( renderer, pos.0, + vel.0, ori.0, scale, col, @@ -367,6 +369,7 @@ impl FigureMgr { state.update( renderer, pos.0, + vel.0, ori.0, scale, col, @@ -385,6 +388,7 @@ impl FigureMgr { state.update( renderer, pos.0, + vel.0, ori.0, scale, col, @@ -524,6 +528,7 @@ impl FigureState { &mut self, renderer: &mut Renderer, pos: Vec3, + vel: Vec3, ori: Vec3, scale: f32, col: Rgba, @@ -535,8 +540,8 @@ impl FigureState { // Update interpolation values if self.pos.distance_squared(pos) < 64.0 * 64.0 { - self.pos = Lerp::lerp(self.pos, pos, 15.0 * dt); - self.ori = Slerp::slerp(self.ori, ori, 7.5 * dt); + self.pos = Lerp::lerp(self.pos, pos + vel * 0.03, 10.0 * dt); + self.ori = Slerp::slerp(self.ori, ori, 5.0 * dt); } else { self.pos = pos; self.ori = ori; diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index c1f4d3884f..c9f1f0ab3a 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -65,7 +65,7 @@ impl Default for ControlSettings { jump: KeyMouse::Key(VirtualKeyCode::Space), sit: KeyMouse::Key(VirtualKeyCode::K), glide: KeyMouse::Key(VirtualKeyCode::LShift), - climb: KeyMouse::Key(VirtualKeyCode::LShift), + climb: KeyMouse::Key(VirtualKeyCode::Space), climb_down: KeyMouse::Key(VirtualKeyCode::LControl), wall_leap: KeyMouse::Mouse(MouseButton::Middle), mount: KeyMouse::Key(VirtualKeyCode::F),