turn off rain for CLOUD_MODE_NONE and adjust iterations

This commit is contained in:
IsseW 2022-06-12 01:42:29 +02:00
parent 80e29e2c20
commit e2969dc5f9
3 changed files with 101 additions and 89 deletions

View File

@ -97,8 +97,7 @@ void main() {
#if (CLOUD_MODE == CLOUD_MODE_NONE) #if (CLOUD_MODE == CLOUD_MODE_NONE)
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 #else
vec3 old_color = color.rgb; vec3 old_color = color.rgb;
dir = (vec4(dir, 0) * rel_rain_dir_mat).xyz; dir = (vec4(dir, 0) * rel_rain_dir_mat).xyz;
@ -115,7 +114,15 @@ void main() {
// and seeing rain. // and seeing rain.
if (medium.x == MEDIUM_AIR && rain_density > 0.0) { if (medium.x == MEDIUM_AIR && rain_density > 0.0) {
float rain_dist = 50.0; float rain_dist = 50.0;
for (int i = 0; i < 4; i ++) { #if (CLOUD_MODE <= CLOUD_MODE_LOW)
int iterations = 2;
#elif (CLOUD_MODE == CLOUD_MODE_MEDIUM)
int iterations = 3;
#else
int iterations = 4;
#endif
for (int i = 0; i < iterations; i ++) {
float old_rain_dist = rain_dist; float old_rain_dist = rain_dist;
rain_dist *= 0.3; rain_dist *= 0.3;
@ -154,6 +161,7 @@ void main() {
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); 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
tgt_color = vec4(color.rgb, 1); tgt_color = vec4(color.rgb, 1);
} }

View File

@ -149,6 +149,7 @@ void main() {
wave_sample_dist / slope wave_sample_dist / slope
); );
#if (CLOUD_MODE != CLOUD_MODE_NONE)
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);
@ -170,6 +171,7 @@ void main() {
* 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));

View File

@ -234,6 +234,7 @@ void main() {
// 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 (CLOUD_MODE != CLOUD_MODE_NONE)
if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) { if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) {
vec3 pos = f_pos + focus_off.xyz; vec3 pos = f_pos + focus_off.xyz;
vec3 drop_density = vec3(2, 2, 2); vec3 drop_density = vec3(2, 2, 2);
@ -261,6 +262,7 @@ void main() {
* 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);