diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 7a22a47711..7f9c885086 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -89,7 +89,7 @@ void main() { vec3 adjusted_dir = (vec4(dir, 0) * rain_dir_mat).xyz; vec2 dir2d = adjusted_dir.xy; - vec3 rorigin = (vec4(cam_wpos, 0) * rain_dir_mat).xyz; + vec3 rorigin = cam_pos.xyz + focus_off.xyz + 0.5; vec3 rpos = vec3(0.0); float t = 0.0; for (int i = 0; i < 6; i ++) { @@ -114,8 +114,8 @@ void main() { if (wpos_dist > dist) { break; } if (rain_occlusion_at(wpos) > 0.5) { - if (length((fract(wall_pos.xz) - 0.5)) < 0.1) { - float alpha = 0.5 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0); + if (length((fract(wall_pos.xz) - 0.5)) < 0.1 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) { + float alpha = 0.9 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0); float light = sqrt(dot(color.rgb, vec3(1))) + (get_sun_brightness() + get_moon_brightness()) * 0.01; color.rgb = mix(color.rgb, vec3(0.2, 0.3, 0.5) * light, alpha); } diff --git a/common/src/weather.rs b/common/src/weather.rs index be39dc73a3..15008774bf 100644 --- a/common/src/weather.rs +++ b/common/src/weather.rs @@ -42,7 +42,7 @@ impl Weather { // Get the rain velocity for this weather pub fn rain_vel(&self) -> Vec3 { - const FALL_RATE: f32 = 20.0; + const FALL_RATE: f32 = 30.0; Vec3::new(self.wind.x, self.wind.y, -FALL_RATE) } } diff --git a/server/src/weather/sim.rs b/server/src/weather/sim.rs index 50612bcbc8..d12b474e27 100644 --- a/server/src/weather/sim.rs +++ b/server/src/weather/sim.rs @@ -9,7 +9,7 @@ use world::World; use crate::weather::WEATHER_DT; -fn cell_to_wpos(p: Vec2) -> Vec2 { p * CELL_SIZE as i32 } +fn cell_to_wpos_center(p: Vec2) -> Vec2 { p * CELL_SIZE as i32 + CELL_SIZE as i32 / 2 } #[derive(Clone)] struct WeatherZone { @@ -49,7 +49,7 @@ impl WeatherSim { } } let average_humid = humid_sum / (CHUNKS_PER_CELL * CHUNKS_PER_CELL) as f32; - let rain_factor = (2.0 * average_humid.powf(0.2)).min(1.0); + let rain_factor = (4.0 * average_humid.powf(0.2)).min(1.0); CellConsts { rain_factor } }) .collect::>(), @@ -82,7 +82,7 @@ impl WeatherSim { } // Time step is cell size / maximum wind speed - pub fn tick(&mut self, time_of_day: &TimeOfDay, out: &mut WeatherGrid) { + pub fn tick(&mut self, world: &World, time_of_day: &TimeOfDay, out: &mut WeatherGrid) { let time = time_of_day.0; let base_nz = Turbulence::new( @@ -103,7 +103,12 @@ impl WeatherSim { self.zones[point] = None; } } else { - let wpos = cell_to_wpos(point); + let wpos = cell_to_wpos_center(point); + + let humid = world + .sim() + .get_wpos(wpos) + .map_or(1.0, |c| c.get_environment().humid); let pos = wpos.as_::() + time as f64 * 0.1; @@ -112,10 +117,11 @@ impl WeatherSim { let spos = (pos / space_scale).with_z(time as f64 / time_scale); let pressure = - (base_nz.get(spos.into_array()) * 0.5 + 1.0).clamped(0.0, 1.0) as f32; + (base_nz.get(spos.into_array()) * 0.5 + 1.0).clamped(0.0, 1.0) as f32 + 0.4 + - humid * 0.5; - const RAIN_CLOUD_THRESHOLD: f32 = 0.26; - cell.cloud = (1.0 - pressure) * 0.5; + const RAIN_CLOUD_THRESHOLD: f32 = 0.2; + cell.cloud = (1.0 - pressure).max(0.0) * 0.5; cell.rain = (1.0 - pressure - RAIN_CLOUD_THRESHOLD).max(0.0) * self.consts[point].rain_factor; cell.wind = Vec2::new( diff --git a/server/src/weather/tick.rs b/server/src/weather/tick.rs index db5154b73c..8dcfe2e94f 100644 --- a/server/src/weather/tick.rs +++ b/server/src/weather/tick.rs @@ -1,6 +1,7 @@ use common::{resources::TimeOfDay, weather::WeatherGrid}; use common_ecs::{Origin, Phase, System}; -use specs::{Read, Write, WriteExpect}; +use specs::{Read, ReadExpect, Write, WriteExpect}; +use std::sync::Arc; use crate::sys::SysScheduler; @@ -12,6 +13,7 @@ pub struct Sys; impl<'a> System<'a> for Sys { type SystemData = ( Read<'a, TimeOfDay>, + ReadExpect<'a, Arc>, WriteExpect<'a, WeatherSim>, WriteExpect<'a, WeatherGrid>, Write<'a, SysScheduler>, @@ -23,13 +25,13 @@ impl<'a> System<'a> for Sys { fn run( _job: &mut common_ecs::Job, - (game_time, mut sim, mut grid, mut scheduler): Self::SystemData, + (game_time, world, mut sim, mut grid, mut scheduler): Self::SystemData, ) { if scheduler.should_run() { if grid.size() != sim.size() { *grid = WeatherGrid::new(sim.size()); } - sim.tick(&game_time, &mut grid); + sim.tick(&world, &game_time, &mut grid); } } }