From 6d8cbe6f0f9adf45b633be084c5f77f82a7f8374 Mon Sep 17 00:00:00 2001 From: IsseW Date: Sat, 2 Jul 2022 12:00:02 +0200 Subject: [PATCH] remove relative rain direction and increase FALL_RATE --- assets/voxygen/shaders/clouds-frag.glsl | 2 +- assets/voxygen/shaders/include/rain_occlusion.glsl | 2 +- .../shaders/rain-occlusion-directed-vert.glsl | 2 +- .../voxygen/shaders/rain-occlusion-figure-vert.glsl | 2 +- common/src/weather.rs | 2 +- voxygen/src/render/pipelines/rain_occlusion.rs | 6 +++--- voxygen/src/scene/mod.rs | 13 ++++--------- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 5cef758dd6..01faedb424 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -86,7 +86,7 @@ void main() { vec3 old_color = color.rgb; // normalized direction from the camera position to the fragment in world, transformed by the relative rain direction - vec3 adjusted_dir = (vec4(dir, 0) * rel_rain_dir_mat).xyz; + vec3 adjusted_dir = (vec4(dir, 0) * rain_dir_mat).xyz; // stretch z values as they move away from 0 float z = (-1 / (abs(adjusted_dir.z) - 1) - 1) * sign(adjusted_dir.z); diff --git a/assets/voxygen/shaders/include/rain_occlusion.glsl b/assets/voxygen/shaders/include/rain_occlusion.glsl index ceef0c8bf3..5f525c282f 100644 --- a/assets/voxygen/shaders/include/rain_occlusion.glsl +++ b/assets/voxygen/shaders/include/rain_occlusion.glsl @@ -12,7 +12,7 @@ layout (std140, set = 0, binding = 14) uniform u_rain_occlusion { mat4 rain_occlusion_matrices; mat4 rain_occlusion_texture_mat; - mat4 rel_rain_dir_mat; + mat4 rain_dir_mat; float integrated_rain_vel; float rain_density; vec2 occlusion_dummy; // Fix alignment. diff --git a/assets/voxygen/shaders/rain-occlusion-directed-vert.glsl b/assets/voxygen/shaders/rain-occlusion-directed-vert.glsl index ba3889d2ae..c8bfd187e4 100644 --- a/assets/voxygen/shaders/rain-occlusion-directed-vert.glsl +++ b/assets/voxygen/shaders/rain-occlusion-directed-vert.glsl @@ -28,7 +28,7 @@ layout (std140, set = 0, binding = 14) uniform u_rain_occlusion { mat4 rain_occlusion_matrices; mat4 rain_occlusion_texture_mat; - mat4 rel_rain_dir_mat; + mat4 rain_dir_mat; float integrated_rain_vel; float rain_density; vec2 occlusion_dummy; // Fix alignment. diff --git a/assets/voxygen/shaders/rain-occlusion-figure-vert.glsl b/assets/voxygen/shaders/rain-occlusion-figure-vert.glsl index fe64700e79..b7f940ea2b 100644 --- a/assets/voxygen/shaders/rain-occlusion-figure-vert.glsl +++ b/assets/voxygen/shaders/rain-occlusion-figure-vert.glsl @@ -30,7 +30,7 @@ layout (std140, set = 0, binding = 14) uniform u_rain_occlusion { mat4 rainOcclusionMatrices; mat4 texture_mat; - mat4 rel_rain_dir_mat; + mat4 rain_dir_mat; float integrated_rain_vel; float rain_density; vec2 occlusion_dummy; // Fix alignment. diff --git a/common/src/weather.rs b/common/src/weather.rs index be39dc73a3..b2e163be3a 100644 --- a/common/src/weather.rs +++ b/common/src/weather.rs @@ -42,7 +42,7 @@ impl Weather { // Get the rain velocity for this weather pub fn rain_vel(&self) -> Vec3 { - const FALL_RATE: f32 = 20.0; + const FALL_RATE: f32 = 50.0; Vec3::new(self.wind.x, self.wind.y, -FALL_RATE) } } diff --git a/voxygen/src/render/pipelines/rain_occlusion.rs b/voxygen/src/render/pipelines/rain_occlusion.rs index 86e30255f4..9963b4ccae 100644 --- a/voxygen/src/render/pipelines/rain_occlusion.rs +++ b/voxygen/src/render/pipelines/rain_occlusion.rs @@ -11,7 +11,7 @@ pub struct Locals { rain_occlusion_texture_mat: [[f32; 4]; 4], /// A rotation of the direction of the rain, relative to the players /// velocity. - rel_rain_dir_mat: [[f32; 4]; 4], + rain_dir_mat: [[f32; 4]; 4], /// A value to offset the rain, to make it move over time. integrated_rain_vel: f32, rain_density: f32, @@ -25,14 +25,14 @@ impl Locals { pub fn new( rain_occlusion_matrices: Mat4, rain_occlusion_texture_mat: Mat4, - rel_rain_dir_mat: Mat4, + rain_dir_mat: Mat4, rain_density: f32, integrated_rain_vel: f32, ) -> Self { Self { rain_occlusion_matrices: rain_occlusion_matrices.into_col_arrays(), rain_occlusion_texture_mat: rain_occlusion_texture_mat.into_col_arrays(), - rel_rain_dir_mat: rel_rain_dir_mat.into_col_arrays(), + rain_dir_mat: rain_dir_mat.into_col_arrays(), integrated_rain_vel, rain_density, occlusion_dummy: [0.0; 2], diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 3014a45eca..46fb837a76 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -488,11 +488,6 @@ impl Scene { .get(scene_data.player_entity) .map_or(Vec3::zero(), |pos| pos.0); - let player_vel = ecs - .read_storage::() - .get(scene_data.player_entity) - .map_or(Vec3::zero(), |vel| vel.0); - let player_rolling = ecs .read_storage::() .get(scene_data.player_entity) @@ -1016,9 +1011,9 @@ impl Scene { let weather = client.state().weather_at(focus_off.xy() + cam_pos.xy()); let rain_vel = weather.rain_vel(); let rain_view_mat = math::Mat4::look_at_rh(look_at, look_at + rain_vel, up); - let relative_rain_vel = rain_vel - player_vel; - self.integrated_rain_vel += relative_rain_vel.magnitude() * dt; - let rel_rain_dir_mat = Mat4::rotation_from_to_3d(-Vec3::unit_z(), relative_rain_vel); + + self.integrated_rain_vel += rain_vel.magnitude() * dt; + let rain_dir_mat = Mat4::rotation_from_to_3d(-Vec3::unit_z(), rain_vel); let (shadow_mat, texture_mat) = directed_mats(rain_view_mat, rain_vel.into(), &visible_occlusion_volume); @@ -1026,7 +1021,7 @@ impl Scene { let rain_occlusion_locals = RainOcclusionLocals::new( shadow_mat, texture_mat, - rel_rain_dir_mat, + rain_dir_mat, weather.rain, self.integrated_rain_vel, );