diff --git a/assets/voxygen/shaders/lod-terrain-vert.glsl b/assets/voxygen/shaders/lod-terrain-vert.glsl index 1a144dbe41..073a462196 100644 --- a/assets/voxygen/shaders/lod-terrain-vert.glsl +++ b/assets/voxygen/shaders/lod-terrain-vert.glsl @@ -60,7 +60,7 @@ void main() { // // float surfaceAlt = min(floor(f_pos.z), floor(alt_at_real(cam_pos.xy))); // faces_fluid ? max(ceil(f_pos.z), floor(f_alt)) : floor(f_alt); // f_pos.z -= max(sign(view_distance.x - distance(focus_pos.xy, f_pos.xy)), 0.0) * (32.0 * view_distance.z / 255 + 32.0 * max(0.0, f_pos.z - cam_pos.z)); - f_pos.z -= max(view_distance.x - distance(focus_pos.xy, f_pos.xy), 0.0) * (1.0 + max(0.0, f_pos.z - focus_pos.z)); + f_pos.z -= 0.1 + max(view_distance.x - distance(focus_pos.xy, f_pos.xy), 0.0) * (1.0 + max(0.0, f_pos.z - focus_pos.z)); // vec3 wRayinitial = f_pos; // cam_pos.z < f_pos.z ? f_pos : cam_pos.xyz; // vec3 wRayfinal = cam_pos.xyz; // cam_pos.z < f_pos.z ? cam_pos.xyz : f_pos; diff --git a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs index 56aca955b0..088ffe1407 100644 --- a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs @@ -53,7 +53,8 @@ impl EventMapper for CombatEventMapper { let sfx_event_bus = ecs.read_resource::>(); let mut sfx_emitter = sfx_event_bus.emitter(); - let cam_pos = camera.dependents().cam_pos; + let focus_off = camera.get_focus_pos().map(f32::trunc); + let cam_pos = camera.dependents().cam_pos + focus_off; for (entity, pos, loadout, character) in ( &ecs.entities(), diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 55bff58c96..f551987ebb 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -50,7 +50,8 @@ impl EventMapper for MovementEventMapper { let sfx_event_bus = ecs.read_resource::>(); let mut sfx_emitter = sfx_event_bus.emitter(); - let cam_pos = camera.dependents().cam_pos; + let focus_off = camera.get_focus_pos().map(f32::trunc); + let cam_pos = camera.dependents().cam_pos + focus_off; for (entity, pos, vel, body, physics, character) in ( &ecs.entities(), diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 8c47867aa1..7439e24e72 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -234,8 +234,10 @@ impl SfxMgr { } let ecs = state.ecs(); + let focus_off = camera.get_focus_pos().map(f32::trunc); + let cam_pos = camera.dependents().cam_pos + focus_off; - audio.set_listener_pos(camera.dependents().cam_pos, camera.dependents().cam_dir); + audio.set_listener_pos(cam_pos, camera.dependents().cam_dir); // TODO: replace; deprecated in favor of outcomes self.event_mapper @@ -247,7 +249,7 @@ impl SfxMgr { for event in events { let position = match event.pos { Some(pos) => pos, - _ => camera.dependents().cam_pos, + _ => cam_pos, }; if let Some(item) = self.triggers.get_trigger(&event.sfx) { diff --git a/voxygen/src/scene/lod.rs b/voxygen/src/scene/lod.rs index 01c80c73f0..9dc1092b99 100644 --- a/voxygen/src/scene/lod.rs +++ b/voxygen/src/scene/lod.rs @@ -40,7 +40,10 @@ impl Lod { pub fn get_data(&self) -> &LodData { &self.data } - pub fn set_detail(&mut self, detail: u32) { self.data.tgt_detail = detail.max(100).min(2500); } + pub fn set_detail(&mut self, detail: u32) { + // Make sure the recorded detail is even. + self.data.tgt_detail = detail.max(100).min(2500) - self.data.tgt_detail % 2; + } pub fn maintain(&mut self, renderer: &mut Renderer, _time_of_day: f64) { if self @@ -66,8 +69,12 @@ impl Lod { } fn create_lod_terrain_mesh(detail: u32) -> Mesh { + // detail is even, so we choose odd detail (detail + 1) to create two even + // halves with an empty hole. + let detail = detail + 1; Spiral2d::new() .take((detail * detail) as usize) + .skip(1) .map(|pos| { let x = pos.x + detail as i32 / 2; let y = pos.y + detail as i32 / 2;