mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better rain performance, wetness
This commit is contained in:
parent
4e854a28ff
commit
25c55b6a25
@ -244,22 +244,44 @@ void main() {
|
||||
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 * rain_occlusion_at(f_pos.xyz + vec3(0, 0, 0.25)) * 2.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;
|
||||
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 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 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);
|
||||
#else
|
||||
const float puddle = 1.0;
|
||||
#endif
|
||||
|
||||
if (fract(hash(fract(vec4(cell, 0) * 0.01))) < rain_density * 2.0 && puddle > 0.3) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* k_s = vec3(1); */
|
||||
/* k_d = vec3(0); */
|
||||
/* alpha = 0.3; */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3673,8 +3673,8 @@ fn handle_lightning(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
_target: EcsEntity,
|
||||
args: Vec<String>,
|
||||
action: &ServerChatCommand,
|
||||
_args: Vec<String>,
|
||||
_action: &ServerChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
let pos = position(server, client, "player")?.0;
|
||||
server
|
||||
|
@ -125,7 +125,6 @@ impl WeatherSim {
|
||||
let time_scale = 100_000.0;
|
||||
let spos = (pos / space_scale).with_z(time as f64 / time_scale);
|
||||
|
||||
let scale = 10_000.0;
|
||||
let avg_scale = 20_000.0;
|
||||
let avg_delay = 250_000.0;
|
||||
let pressure = ((base_nz.get(
|
||||
|
@ -478,4 +478,6 @@ pub enum ExperimentalShader {
|
||||
DirectionalShadowMapTexelGrid,
|
||||
/// Enable rainbows
|
||||
Rainbows,
|
||||
/// Make objects appear wet when appropriate.
|
||||
Wetness,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user