diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 2397d0ec4a..e76f1ee464 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -99,59 +99,57 @@ void main() { color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb); #endif - #ifdef EXPERIMENTAL_RAIN - vec3 old_color = color.rgb; + vec3 old_color = color.rgb; - // If this value is changed also change it in common/src/weather.rs - float fall_rate = 70.0; - dir.xy += wind_vel * dir.z / fall_rate; - dir = normalize(dir); + // If this value is changed also change it in common/src/weather.rs + float fall_rate = 70.0; + dir.xy += wind_vel * dir.z / fall_rate; + dir = normalize(dir); - float z = (-1 / (abs(dir.z) - 1) - 1) * sign(dir.z); - vec2 dir_2d = normalize(dir.xy); - vec2 view_pos = vec2(atan2(dir_2d.x, dir_2d.y), z); + float z = (-1 / (abs(dir.z) - 1) - 1) * sign(dir.z); + vec2 dir_2d = normalize(dir.xy); + vec2 view_pos = vec2(atan2(dir_2d.x, dir_2d.y), z); - vec3 cam_wpos = cam_pos.xyz + focus_off.xyz; - float rain_dist = 250.0; - for (int i = 0; i < 7; i ++) { - float old_rain_dist = rain_dist; - rain_dist *= 0.3; + vec3 cam_wpos = cam_pos.xyz + focus_off.xyz; + float rain_dist = 250.0; + for (int i = 0; i < 7; i ++) { + float old_rain_dist = rain_dist; + rain_dist *= 0.3; - vec2 drop_density = vec2(30, 1); + vec2 drop_density = vec2(30, 1); - vec2 rain_pos = (view_pos * rain_dist); - rain_pos += vec2(0, tick.x * fall_rate + cam_wpos.z); + vec2 rain_pos = (view_pos * rain_dist); + rain_pos += vec2(0, tick.x * fall_rate + cam_wpos.z); - vec2 cell = floor(rain_pos * drop_density) / drop_density; + vec2 cell = floor(rain_pos * drop_density) / drop_density; - float drop_depth = mix( - old_rain_dist, - rain_dist, - fract(hash(fract(vec4(cell, rain_dist, 0) * 0.1))) - ); - vec3 rpos = vec3(vec2(dir_2d), view_pos.y) * drop_depth; - float dist_to_rain = length(rpos); - if (dist < dist_to_rain || cam_wpos.z + rpos.z > CLOUD_AVG_ALT) { - continue; - } - - if (dot(rpos * vec3(1, 1, 0.5), rpos) < 1.0) { - break; - } - float rain_density = rain_density_at(cam_wpos.xy + rpos.xy) * rain_occlusion_at(cam_pos.xyz + rpos.xyz) * 10.0; - - if (rain_density < 0.001 || fract(hash(fract(vec4(cell, rain_dist, 0) * 0.01))) > rain_density) { - continue; - } - vec2 near_drop = cell + (vec2(0.5) + (vec2(hash(vec4(cell, 0, 0)), 0.5) - 0.5) * vec2(2, 0)) / drop_density; - - vec2 drop_size = vec2(0.0008, 0.05); - float avg_alpha = (drop_size.x * drop_size.y) * 10 / 1; - float alpha = sign(max(1 - length((rain_pos - near_drop) / drop_size * 0.1), 0)); - float light = sqrt(dot(old_color, vec3(1))) + (get_sun_brightness() + get_moon_brightness()) * 0.01; - color.rgb = mix(color.rgb, vec3(0.3, 0.4, 0.5) * light, mix(avg_alpha, alpha, min(1000 / dist_to_rain, 1)) * 0.25); + float drop_depth = mix( + old_rain_dist, + rain_dist, + fract(hash(fract(vec4(cell, rain_dist, 0) * 0.1))) + ); + vec3 rpos = vec3(vec2(dir_2d), view_pos.y) * drop_depth; + float dist_to_rain = length(rpos); + if (dist < dist_to_rain || cam_wpos.z + rpos.z > CLOUD_AVG_ALT) { + continue; } - #endif + + if (dot(rpos * vec3(1, 1, 0.5), rpos) < 1.0) { + break; + } + float rain_density = rain_density_at(cam_wpos.xy + rpos.xy) * rain_occlusion_at(cam_pos.xyz + rpos.xyz) * 10.0; + + if (rain_density < 0.001 || fract(hash(fract(vec4(cell, rain_dist, 0) * 0.01))) > rain_density) { + continue; + } + vec2 near_drop = cell + (vec2(0.5) + (vec2(hash(vec4(cell, 0, 0)), 0.5) - 0.5) * vec2(2, 0)) / drop_density; + + vec2 drop_size = vec2(0.0008, 0.05); + float avg_alpha = (drop_size.x * drop_size.y) * 10 / 1; + float alpha = sign(max(1 - length((rain_pos - near_drop) / drop_size * 0.1), 0)); + float light = sqrt(dot(old_color, vec3(1))) + (get_sun_brightness() + get_moon_brightness()) * 0.01; + color.rgb = mix(color.rgb, vec3(0.3, 0.4, 0.5) * light, mix(avg_alpha, alpha, min(1000 / dist_to_rain, 1)) * 0.25); + } tgt_color = vec4(color.rgb, 1); } diff --git a/assets/voxygen/shaders/fluid-frag/shiny.glsl b/assets/voxygen/shaders/fluid-frag/shiny.glsl index f91f5fc7d7..334784b835 100644 --- a/assets/voxygen/shaders/fluid-frag/shiny.glsl +++ b/assets/voxygen/shaders/fluid-frag/shiny.glsl @@ -149,30 +149,28 @@ void main() { wave_sample_dist / slope ); - #ifdef EXPERIMENTAL_RAIN - float rain_density = rain_density_at(f_pos.xy + focus_off.xy) * rain_occlusion_at(f_pos.xyz) * 50.0; - if (rain_density > 0 && surf_norm.z > 0.5) { - vec3 drop_density = vec3(2, 2, 2); - vec3 drop_pos = wave_pos + vec3(0, 0, -time_of_day.x * 0.025); - drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10; - vec2 cell2d = floor(drop_pos.xy * drop_density.xy); - drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0)); - vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z)); + float rain_density = rain_density_at(f_pos.xy + focus_off.xy) * rain_occlusion_at(f_pos.xyz) * 50.0; + if (rain_density > 0 && surf_norm.z > 0.5) { + vec3 drop_density = vec3(2, 2, 2); + vec3 drop_pos = wave_pos + vec3(0, 0, -time_of_day.x * 0.025); + drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10; + vec2 cell2d = floor(drop_pos.xy * drop_density.xy); + drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0)); + vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z)); - if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_density) { - vec3 off = vec3(hash_fast(uvec3(cell * 13)), hash_fast(uvec3(cell * 5)), 0); - vec3 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density; + if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_density) { + vec3 off = vec3(hash_fast(uvec3(cell * 13)), hash_fast(uvec3(cell * 5)), 0); + vec3 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density; - float dist = length((drop_pos - near_cell) / vec3(1, 1, 2)); - float drop_rad = 0.125; - nmap.xy += (drop_pos - near_cell).xy - * max(1.0 - abs(dist - drop_rad) * 50, 0) - * 2500 - * sign(dist - drop_rad) - * max(drop_pos.z - near_cell.z, 0); - } + float dist = length((drop_pos - near_cell) / vec3(1, 1, 2)); + float drop_rad = 0.125; + nmap.xy += (drop_pos - near_cell).xy + * max(1.0 - abs(dist - drop_rad) * 50, 0) + * 2500 + * sign(dist - drop_rad) + * max(drop_pos.z - near_cell.z, 0); } - #endif + } nmap = mix(f_norm, normalize(nmap), min(1.0 / pow(frag_dist, 0.75), 1)); diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index e24b27482d..e37eac610f 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -231,39 +231,37 @@ void main() { vec3 k_d = vec3(1.0); vec3 k_s = vec3(R_s); - #ifdef EXPERIMENTAL_RAIN - vec3 pos = f_pos + focus_off.xyz; - float rain_density = rain_density_at(pos.xy) * rain_occlusion_at(f_pos.xyz) * 50.0; - // Toggle to see rain_occlusion - // tgt_color = vec4(rain_occlusion_at(f_pos.xyz), 0.0, 0.0, 1.0); - // return; - if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) { - vec3 drop_density = vec3(2, 2, 2); - vec3 drop_pos = pos + vec3(pos.zz, 0) + vec3(0, 0, -tick.x * 1.0); - drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10; - vec2 cell2d = floor(drop_pos.xy * drop_density.xy); - drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0)); - vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z)); + vec3 pos = f_pos + focus_off.xyz; + float rain_density = rain_density_at(pos.xy) * rain_occlusion_at(f_pos.xyz) * 50.0; + // Toggle to see rain_occlusion + // tgt_color = vec4(rain_occlusion_at(f_pos.xyz), 0.0, 0.0, 1.0); + // return; + if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) { + vec3 drop_density = vec3(2, 2, 2); + vec3 drop_pos = pos + vec3(pos.zz, 0) + vec3(0, 0, -tick.x * 1.0); + drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10; + vec2 cell2d = floor(drop_pos.xy * drop_density.xy); + drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0)); + vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z)); - if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_density) { - vec3 off = vec3(hash_fast(uvec3(cell * 13)), hash_fast(uvec3(cell * 5)), 0); - vec3 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density; + if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_density) { + vec3 off = vec3(hash_fast(uvec3(cell * 13)), hash_fast(uvec3(cell * 5)), 0); + vec3 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density; - float dist = length((drop_pos - near_cell) / vec3(1, 1, 2)); - float drop_rad = 0.1; - float distort = max(1.0 - abs(dist - drop_rad) * 100, 0) * 1.5 * max(drop_pos.z - near_cell.z, 0); - k_a += distort; - k_d += distort; - k_s += distort; - f_norm.xy += (drop_pos - near_cell).xy - * max(1.0 - abs(dist - drop_rad) * 30, 0) - * 500.0 - * max(drop_pos.z - near_cell.z, 0) - * sign(dist - drop_rad) - * max(drop_pos.z - near_cell.z, 0); - } + float dist = length((drop_pos - near_cell) / vec3(1, 1, 2)); + float drop_rad = 0.1; + float distort = max(1.0 - abs(dist - drop_rad) * 100, 0) * 1.5 * max(drop_pos.z - near_cell.z, 0); + k_a += distort; + k_d += distort; + k_s += distort; + f_norm.xy += (drop_pos - near_cell).xy + * max(1.0 - abs(dist - drop_rad) * 30, 0) + * 500.0 + * max(drop_pos.z - near_cell.z, 0) + * sign(dist - drop_rad) + * max(drop_pos.z - near_cell.z, 0); } - #endif + } // float sun_light = get_sun_brightness(sun_dir); // float moon_light = get_moon_brightness(moon_dir); diff --git a/server/src/weather/sim.rs b/server/src/weather/sim.rs index 8c5e8fac7f..51ad06621d 100644 --- a/server/src/weather/sim.rs +++ b/server/src/weather/sim.rs @@ -6,8 +6,6 @@ use noise::{NoiseFn, SuperSimplex, Turbulence}; use vek::*; use world::World; - - /* #[derive(Clone, Copy, Default)] struct Cell { diff --git a/voxygen/src/audio/mod.rs b/voxygen/src/audio/mod.rs index 1f00c4b454..92f6808493 100644 --- a/voxygen/src/audio/mod.rs +++ b/voxygen/src/audio/mod.rs @@ -360,7 +360,9 @@ impl AudioFrontend { channel_tag: AmbientChannelTag, ) -> Option<&mut AmbientChannel> { if self.audio_stream.is_some() { - self.ambient_channels.iter_mut().find(|channel| channel.get_tag() == channel_tag) + self.ambient_channels + .iter_mut() + .find(|channel| channel.get_tag() == channel_tag) } else { None } diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 206fd7962e..a88e2f686f 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -476,8 +476,6 @@ pub enum ExperimentalShader { /// Display grid lines to visualize the distribution of shadow map texels /// for the directional light from the sun. DirectionalShadowMapTexelGrid, - /// Enable rain, unfinished and goes through blocks - Rain, /// Enable rainbows Rainbows, }