diff --git a/assets/voxygen/shaders/include/cloud/regular.glsl b/assets/voxygen/shaders/include/cloud/regular.glsl index 412f463340..8ff0ff15e8 100644 --- a/assets/voxygen/shaders/include/cloud/regular.glsl +++ b/assets/voxygen/shaders/include/cloud/regular.glsl @@ -242,7 +242,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of int i; #if (CLOUD_MODE >= CLOUD_MODE_MEDIUM) - #ifdef EXPERIMENTAL_RAINBOWS + #ifndef EXPERIMENTAL_NORAINBOWS // TODO: Make it a double rainbow float rainbow_t = (0.7 - dot(sun_dir.xyz, dir)) * 8 / 0.05; int rainbow_c = int(floor(rainbow_t)); @@ -285,7 +285,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of // Rainbow #if (CLOUD_MODE >= CLOUD_MODE_MEDIUM) - #ifdef EXPERIMENTAL_RAINBOWS + #ifndef EXPERIMENTAL_NORAINBOWS if (rainbow_c >= 0 && rainbow_c < 8) { vec3 colors[9] = { surf_color, diff --git a/assets/voxygen/shaders/include/point_glow.glsl b/assets/voxygen/shaders/include/point_glow.glsl index 96b03abdcf..5b01963b48 100644 --- a/assets/voxygen/shaders/include/point_glow.glsl +++ b/assets/voxygen/shaders/include/point_glow.glsl @@ -55,7 +55,8 @@ vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color) { apply_point_glow_light(L, wpos, dir, max_dist, color); } #endif - if (tick.x - last_lightning.w < 5.0) { + float time_since_lightning = tick.x - last_lightning.w; + if (time_since_lightning < MAX_LIGHTNING_PERIOD) { // Apply lightning apply_point_glow_light(Light(last_lightning.xyzw + vec4(0, 0, LIGHTNING_HEIGHT, 0), vec4(vec3(0.2, 0.4, 1) * lightning_intensity() * 0.003, 1)), wpos, dir, max_dist, color); } diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 5b96d8fb6a..c41cbb417b 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -233,6 +233,7 @@ DirectionalLight get_moon_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]* } const float LIGHTNING_HEIGHT = 25.0; +const float MAX_LIGHTNING_PERIOD = 5.0; float lightning_intensity() { float time_since_lightning = tick.x - last_lightning.w; @@ -247,7 +248,7 @@ float lightning_intensity() { vec3 lightning_at(vec3 wpos) { float time_since_lightning = tick.x - last_lightning.w; - if (time_since_lightning < 5.0) { + if (time_since_lightning < MAX_LIGHTNING_PERIOD) { vec3 diff = wpos + focus_off.xyz - (last_lightning.xyz + vec3(0, 0, LIGHTNING_HEIGHT)); float dist = length(diff); return vec3(0.5, 0.8, 1.0) diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index 85c91d98a1..f6605f5727 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -246,17 +246,7 @@ void main() { if (rain_occlusion_at(f_pos.xyz + vec3(0, 0, 0.25)) > 0.5) { #ifdef EXPERIMENTAL_WETNESS - float puddle = clamp((noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.1) - 0.5) * 20.0, 0.0, 1.0);// * pow(rain_density, 0.05); - - float h = (noise_2d((f_pos.xy + focus_off.xy) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + (noise_2d((f_pos.xy + focus_off.xy) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); - float hx = (noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + (noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); - float hy = (noise_2d((f_pos.xy + focus_off.xy + vec2(0, 0.1)) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + (noise_2d((f_pos.xy + focus_off.xy + vec2(0, 0.1)) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); - f_norm.xy += mix(vec2(0), vec2(h - hx, h - hy) / 0.1 * 0.03, puddle); - alpha = mix(1.0, 0.2, puddle); - f_col.rgb *= mix(1.0, 0.7, puddle); - /* k_a += 1.0; */ - /* k_d += 1.0; */ - k_s = mix(k_s, vec3(0.7, 0.7, 1.0), puddle); + float puddle = clamp((noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.03) - 0.5) * 20.0, 0.0, 1.0) * min(rain_density * 10.0, 1.0); #else const float puddle = 1.0; #endif @@ -271,6 +261,11 @@ void main() { k_a += distort; k_d += distort; k_s += distort; + + #ifdef EXPERIMENTAL_WETNESS + /* puddle = mix(puddle, 1.0, distort * 10); */ + #endif + f_norm.xy += (drop_pos - near_cell).xy * max(1.0 - abs(dist - drop_rad) * 30, 0) * 500.0 @@ -279,9 +274,20 @@ void main() { * max(drop_pos.z - near_cell.z, 0); } - /* k_s = vec3(1); */ - /* k_d = vec3(0); */ - /* alpha = 0.3; */ + #ifdef EXPERIMENTAL_WETNESS + if (puddle > 0.0) { + float h = (noise_2d((f_pos.xy + focus_off.xy) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + + (noise_2d((f_pos.xy + focus_off.xy) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); + float hx = (noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + + (noise_2d((f_pos.xy + focus_off.xy + vec2(0.1, 0)) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); + float hy = (noise_2d((f_pos.xy + focus_off.xy + vec2(0, 0.1)) * 0.3) - 0.5) * sin(tick.x * 8.0 + f_pos.x * 3) + + (noise_2d((f_pos.xy + focus_off.xy + vec2(0, 0.1)) * 0.6) - 0.5) * sin(tick.x * 3.5 - f_pos.y * 6); + f_norm.xy += mix(vec2(0), vec2(h - hx, h - hy) / 0.1 * 0.03, puddle); + alpha = mix(1.0, 0.2, puddle); + f_col.rgb *= mix(1.0, 0.7, puddle); + k_s = mix(k_s, vec3(0.7, 0.7, 1.0), puddle); + } + #endif } } #endif diff --git a/server/src/weather/sim.rs b/server/src/weather/sim.rs index 94eb77883f..6832c5e1e1 100644 --- a/server/src/weather/sim.rs +++ b/server/src/weather/sim.rs @@ -23,7 +23,6 @@ struct WeatherZone { struct CellConsts { humidity: f32, - alt: f32, } pub struct WeatherSim { @@ -55,10 +54,6 @@ impl WeatherSim { let average_humid = humid_sum / (CHUNKS_PER_CELL * CHUNKS_PER_CELL) as f32; CellConsts { humidity: average_humid.powf(0.2).min(1.0), - alt: world - .sim() - .get_alt_approx(cell_to_wpos_center(p.map(|e| e as i32))) - .unwrap_or(world::CONFIG.sea_level), } }) .collect::>(), @@ -96,6 +91,7 @@ impl WeatherSim { time_of_day: &TimeOfDay, outcomes: &EventBus, out: &mut WeatherGrid, + world: &World, ) { let time = time_of_day.0; @@ -155,8 +151,11 @@ impl WeatherSim { * (1.0 - pressure); if cell.rain > 0.2 && cell.cloud > 0.15 && thread_rng().gen_bool(0.01) { + let wpos = wpos.map(|e| { + e as f32 + thread_rng().gen_range(-1.0..1.0) * CELL_SIZE as f32 * 0.5 + }); outcomes.emit_now(Outcome::Lightning { - pos: wpos.map(|e| e as f32).with_z(self.consts[point].alt), + pos: wpos.with_z(world.sim().get_alt_approx(wpos.as_()).unwrap_or(0.0)), }); } } diff --git a/server/src/weather/tick.rs b/server/src/weather/tick.rs index 7e3273fd1d..c52bf0c99a 100644 --- a/server/src/weather/tick.rs +++ b/server/src/weather/tick.rs @@ -1,6 +1,8 @@ use common::{event::EventBus, outcome::Outcome, resources::TimeOfDay, weather::WeatherGrid}; use common_ecs::{Origin, Phase, System}; use specs::{Read, ReadExpect, Write, WriteExpect}; +use std::sync::Arc; +use world::World; use crate::sys::SysScheduler; @@ -16,6 +18,7 @@ impl<'a> System<'a> for Sys { WriteExpect<'a, WeatherGrid>, Write<'a, SysScheduler>, ReadExpect<'a, EventBus>, + ReadExpect<'a, Arc>, ); const NAME: &'static str = "weather::tick"; @@ -24,13 +27,13 @@ impl<'a> System<'a> for Sys { fn run( _job: &mut common_ecs::Job, - (game_time, mut sim, mut grid, mut scheduler, outcomes): Self::SystemData, + (game_time, mut sim, mut grid, mut scheduler, outcomes, world): Self::SystemData, ) { if scheduler.should_run() { if grid.size() != sim.size() { *grid = WeatherGrid::new(sim.size()); } - sim.tick(&game_time, &outcomes, &mut grid); + sim.tick(&game_time, &outcomes, &mut grid, &world); } } } diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 63433ddcfc..d28835fc0f 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -476,8 +476,8 @@ pub enum ExperimentalShader { /// Display grid lines to visualize the distribution of shadow map texels /// for the directional light from the sun. DirectionalShadowMapTexelGrid, - /// Enable rainbows - Rainbows, + /// Disable rainbows + NoRainbows, /// Make objects appear wet when appropriate. Wetness, }