remove relative rain direction and increase FALL_RATE

This commit is contained in:
IsseW 2022-07-02 12:00:02 +02:00
parent 6562c7076f
commit 6d8cbe6f0f
7 changed files with 12 additions and 17 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -42,7 +42,7 @@ impl Weather {
// Get the rain velocity for this weather
pub fn rain_vel(&self) -> Vec3<f32> {
const FALL_RATE: f32 = 20.0;
const FALL_RATE: f32 = 50.0;
Vec3::new(self.wind.x, self.wind.y, -FALL_RATE)
}
}

View File

@ -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<f32>,
rain_occlusion_texture_mat: Mat4<f32>,
rel_rain_dir_mat: Mat4<f32>,
rain_dir_mat: Mat4<f32>,
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],

View File

@ -488,11 +488,6 @@ impl Scene {
.get(scene_data.player_entity)
.map_or(Vec3::zero(), |pos| pos.0);
let player_vel = ecs
.read_storage::<comp::Vel>()
.get(scene_data.player_entity)
.map_or(Vec3::zero(), |vel| vel.0);
let player_rolling = ecs
.read_storage::<comp::CharacterState>()
.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,
);