Balanced rain density

This commit is contained in:
Joshua Barretto 2022-03-13 16:35:52 +00:00 committed by IsseW
parent 273c5ed2f0
commit 4181331e6b
3 changed files with 7 additions and 7 deletions

View File

@ -112,7 +112,7 @@ void main() {
vec2 view_pos = vec2(atan2(dir_2d.x, dir_2d.y), z);
vec3 cam_wpos = cam_pos.xyz + focus_off.xyz;
float rain_density = rain_density_at(cam_wpos.xy);
float rain_density = rain_density_at(cam_wpos.xy) * 100.0;
if (rain_density > 0) {
float rain_dist = 50.0;
for (int i = 0; i < 5; i ++) {
@ -132,7 +132,7 @@ void main() {
rain_pos += vec2(0, tick.x * fall_rate + cam_wpos.z);
vec2 cell = floor(rain_pos * drop_density) / drop_density;
if (hash(fract(vec4(cell, rain_dist, 0) * 0.01)) > rain_density) {
if (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;

View File

@ -150,7 +150,7 @@ void main() {
);
#ifdef EXPERIMENTAL_RAIN
float rain_density = rain_density_at(cam_pos.xy + focus_off.xy);
float rain_density = rain_density_at(cam_pos.xy + focus_off.xy) * 100.0;
if (rain_density > 0 && surf_norm.z > 0.5) {
vec3 drop_density = vec3(2, 2, 1);
vec3 drop_pos = wave_pos + vec3(0, 0, -time_of_day.x * 0.025);
@ -159,7 +159,7 @@ void main() {
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
if (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 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density;

View File

@ -230,9 +230,9 @@ void main() {
vec3 k_a = vec3(1.0);
vec3 k_d = vec3(1.0);
vec3 k_s = vec3(R_s);
#ifdef EXPERIMENTAL_RAIN
float rain_density = rain_density_at(cam_pos.xy + focus_off.xy);
float rain_density = rain_density_at(cam_pos.xy + focus_off.xy) * 100.0;
if (rain_density > 0 && !faces_fluid && f_norm.z > 0.5) {
vec3 pos = f_pos + focus_off.xyz;
vec3 drop_density = vec3(2, 2, 1);
@ -242,7 +242,7 @@ void main() {
drop_pos.z *= 0.5 + hash_fast(uvec3(cell2d, 0));
vec3 cell = vec3(cell2d, floor(drop_pos.z * drop_density.z));
if (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 near_cell = (cell + 0.5 + (off - 0.5) * 0.5) / drop_density;