mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Don't have rain be behind an expiremental shader
This commit is contained in:
parent
6274d54e56
commit
b82bb5b247
@ -99,59 +99,57 @@ void main() {
|
|||||||
color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb);
|
color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb);
|
||||||
#endif
|
#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
|
// If this value is changed also change it in common/src/weather.rs
|
||||||
float fall_rate = 70.0;
|
float fall_rate = 70.0;
|
||||||
dir.xy += wind_vel * dir.z / fall_rate;
|
dir.xy += wind_vel * dir.z / fall_rate;
|
||||||
dir = normalize(dir);
|
dir = normalize(dir);
|
||||||
|
|
||||||
float z = (-1 / (abs(dir.z) - 1) - 1) * sign(dir.z);
|
float z = (-1 / (abs(dir.z) - 1) - 1) * sign(dir.z);
|
||||||
vec2 dir_2d = normalize(dir.xy);
|
vec2 dir_2d = normalize(dir.xy);
|
||||||
vec2 view_pos = vec2(atan2(dir_2d.x, dir_2d.y), z);
|
vec2 view_pos = vec2(atan2(dir_2d.x, dir_2d.y), z);
|
||||||
|
|
||||||
vec3 cam_wpos = cam_pos.xyz + focus_off.xyz;
|
vec3 cam_wpos = cam_pos.xyz + focus_off.xyz;
|
||||||
float rain_dist = 250.0;
|
float rain_dist = 250.0;
|
||||||
for (int i = 0; i < 7; i ++) {
|
for (int i = 0; i < 7; i ++) {
|
||||||
float old_rain_dist = rain_dist;
|
float old_rain_dist = rain_dist;
|
||||||
rain_dist *= 0.3;
|
rain_dist *= 0.3;
|
||||||
|
|
||||||
vec2 drop_density = vec2(30, 1);
|
vec2 drop_density = vec2(30, 1);
|
||||||
|
|
||||||
vec2 rain_pos = (view_pos * rain_dist);
|
vec2 rain_pos = (view_pos * rain_dist);
|
||||||
rain_pos += vec2(0, tick.x * fall_rate + cam_wpos.z);
|
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(
|
float drop_depth = mix(
|
||||||
old_rain_dist,
|
old_rain_dist,
|
||||||
rain_dist,
|
rain_dist,
|
||||||
fract(hash(fract(vec4(cell, rain_dist, 0) * 0.1)))
|
fract(hash(fract(vec4(cell, rain_dist, 0) * 0.1)))
|
||||||
);
|
);
|
||||||
vec3 rpos = vec3(vec2(dir_2d), view_pos.y) * drop_depth;
|
vec3 rpos = vec3(vec2(dir_2d), view_pos.y) * drop_depth;
|
||||||
float dist_to_rain = length(rpos);
|
float dist_to_rain = length(rpos);
|
||||||
if (dist < dist_to_rain || cam_wpos.z + rpos.z > CLOUD_AVG_ALT) {
|
if (dist < dist_to_rain || cam_wpos.z + rpos.z > CLOUD_AVG_ALT) {
|
||||||
continue;
|
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);
|
|
||||||
}
|
}
|
||||||
#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);
|
tgt_color = vec4(color.rgb, 1);
|
||||||
}
|
}
|
||||||
|
@ -149,30 +149,28 @@ void main() {
|
|||||||
wave_sample_dist / slope
|
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;
|
||||||
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) {
|
||||||
if (rain_density > 0 && surf_norm.z > 0.5) {
|
vec3 drop_density = vec3(2, 2, 2);
|
||||||
vec3 drop_density = vec3(2, 2, 2);
|
vec3 drop_pos = wave_pos + vec3(0, 0, -time_of_day.x * 0.025);
|
||||||
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;
|
||||||
drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10;
|
vec2 cell2d = floor(drop_pos.xy * drop_density.xy);
|
||||||
vec2 cell2d = floor(drop_pos.xy * drop_density.xy);
|
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
|
||||||
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
|
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
|
||||||
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
|
|
||||||
|
|
||||||
if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_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 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;
|
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 dist = length((drop_pos - near_cell) / vec3(1, 1, 2));
|
||||||
float drop_rad = 0.125;
|
float drop_rad = 0.125;
|
||||||
nmap.xy += (drop_pos - near_cell).xy
|
nmap.xy += (drop_pos - near_cell).xy
|
||||||
* max(1.0 - abs(dist - drop_rad) * 50, 0)
|
* max(1.0 - abs(dist - drop_rad) * 50, 0)
|
||||||
* 2500
|
* 2500
|
||||||
* sign(dist - drop_rad)
|
* sign(dist - drop_rad)
|
||||||
* max(drop_pos.z - near_cell.z, 0);
|
* max(drop_pos.z - near_cell.z, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
nmap = mix(f_norm, normalize(nmap), min(1.0 / pow(frag_dist, 0.75), 1));
|
nmap = mix(f_norm, normalize(nmap), min(1.0 / pow(frag_dist, 0.75), 1));
|
||||||
|
|
||||||
|
@ -231,39 +231,37 @@ void main() {
|
|||||||
vec3 k_d = vec3(1.0);
|
vec3 k_d = vec3(1.0);
|
||||||
vec3 k_s = vec3(R_s);
|
vec3 k_s = vec3(R_s);
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_RAIN
|
vec3 pos = f_pos + focus_off.xyz;
|
||||||
vec3 pos = f_pos + focus_off.xyz;
|
float rain_density = rain_density_at(pos.xy) * rain_occlusion_at(f_pos.xyz) * 50.0;
|
||||||
float rain_density = rain_density_at(pos.xy) * rain_occlusion_at(f_pos.xyz) * 50.0;
|
// Toggle to see rain_occlusion
|
||||||
// Toggle to see rain_occlusion
|
// tgt_color = vec4(rain_occlusion_at(f_pos.xyz), 0.0, 0.0, 1.0);
|
||||||
// tgt_color = vec4(rain_occlusion_at(f_pos.xyz), 0.0, 0.0, 1.0);
|
// return;
|
||||||
// return;
|
if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) {
|
||||||
if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) {
|
vec3 drop_density = vec3(2, 2, 2);
|
||||||
vec3 drop_density = vec3(2, 2, 2);
|
vec3 drop_pos = pos + vec3(pos.zz, 0) + vec3(0, 0, -tick.x * 1.0);
|
||||||
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;
|
||||||
drop_pos.z += noise_2d(floor(drop_pos.xy * drop_density.xy) * 13.1) * 10;
|
vec2 cell2d = floor(drop_pos.xy * drop_density.xy);
|
||||||
vec2 cell2d = floor(drop_pos.xy * drop_density.xy);
|
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
|
||||||
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
|
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
|
||||||
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
|
|
||||||
|
|
||||||
if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_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 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;
|
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 dist = length((drop_pos - near_cell) / vec3(1, 1, 2));
|
||||||
float drop_rad = 0.1;
|
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);
|
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_a += distort;
|
||||||
k_d += distort;
|
k_d += distort;
|
||||||
k_s += distort;
|
k_s += distort;
|
||||||
f_norm.xy += (drop_pos - near_cell).xy
|
f_norm.xy += (drop_pos - near_cell).xy
|
||||||
* max(1.0 - abs(dist - drop_rad) * 30, 0)
|
* max(1.0 - abs(dist - drop_rad) * 30, 0)
|
||||||
* 500.0
|
* 500.0
|
||||||
* max(drop_pos.z - near_cell.z, 0)
|
* max(drop_pos.z - near_cell.z, 0)
|
||||||
* sign(dist - drop_rad)
|
* sign(dist - drop_rad)
|
||||||
* max(drop_pos.z - near_cell.z, 0);
|
* max(drop_pos.z - near_cell.z, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// float sun_light = get_sun_brightness(sun_dir);
|
// float sun_light = get_sun_brightness(sun_dir);
|
||||||
// float moon_light = get_moon_brightness(moon_dir);
|
// float moon_light = get_moon_brightness(moon_dir);
|
||||||
|
@ -6,8 +6,6 @@ use noise::{NoiseFn, SuperSimplex, Turbulence};
|
|||||||
use vek::*;
|
use vek::*;
|
||||||
use world::World;
|
use world::World;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#[derive(Clone, Copy, Default)]
|
#[derive(Clone, Copy, Default)]
|
||||||
struct Cell {
|
struct Cell {
|
||||||
|
@ -360,7 +360,9 @@ impl AudioFrontend {
|
|||||||
channel_tag: AmbientChannelTag,
|
channel_tag: AmbientChannelTag,
|
||||||
) -> Option<&mut AmbientChannel> {
|
) -> Option<&mut AmbientChannel> {
|
||||||
if self.audio_stream.is_some() {
|
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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -476,8 +476,6 @@ pub enum ExperimentalShader {
|
|||||||
/// Display grid lines to visualize the distribution of shadow map texels
|
/// Display grid lines to visualize the distribution of shadow map texels
|
||||||
/// for the directional light from the sun.
|
/// for the directional light from the sun.
|
||||||
DirectionalShadowMapTexelGrid,
|
DirectionalShadowMapTexelGrid,
|
||||||
/// Enable rain, unfinished and goes through blocks
|
|
||||||
Rain,
|
|
||||||
/// Enable rainbows
|
/// Enable rainbows
|
||||||
Rainbows,
|
Rainbows,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user