mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better cloud cover
This commit is contained in:
parent
853d622e19
commit
28bc9db198
@ -89,7 +89,7 @@ void main() {
|
||||
vec3 adjusted_dir = (vec4(dir, 0) * rain_dir_mat).xyz;
|
||||
|
||||
vec2 dir2d = adjusted_dir.xy;
|
||||
vec3 rorigin = (vec4(cam_wpos, 0) * rain_dir_mat).xyz;
|
||||
vec3 rorigin = cam_pos.xyz + focus_off.xyz + 0.5;
|
||||
vec3 rpos = vec3(0.0);
|
||||
float t = 0.0;
|
||||
for (int i = 0; i < 6; i ++) {
|
||||
@ -114,8 +114,8 @@ void main() {
|
||||
|
||||
if (wpos_dist > dist) { break; }
|
||||
if (rain_occlusion_at(wpos) > 0.5) {
|
||||
if (length((fract(wall_pos.xz) - 0.5)) < 0.1) {
|
||||
float alpha = 0.5 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0);
|
||||
if (length((fract(wall_pos.xz) - 0.5)) < 0.1 + pow(max(0.0, wpos_dist - (dist - 0.25)) / 0.25, 4.0) * 0.2) {
|
||||
float alpha = 0.9 * clamp((wpos_dist - 1.0) * 0.5, 0.0, 1.0);
|
||||
float light = sqrt(dot(color.rgb, vec3(1))) + (get_sun_brightness() + get_moon_brightness()) * 0.01;
|
||||
color.rgb = mix(color.rgb, vec3(0.2, 0.3, 0.5) * light, alpha);
|
||||
}
|
||||
|
@ -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 = 30.0;
|
||||
Vec3::new(self.wind.x, self.wind.y, -FALL_RATE)
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use world::World;
|
||||
|
||||
use crate::weather::WEATHER_DT;
|
||||
|
||||
fn cell_to_wpos(p: Vec2<i32>) -> Vec2<i32> { p * CELL_SIZE as i32 }
|
||||
fn cell_to_wpos_center(p: Vec2<i32>) -> Vec2<i32> { p * CELL_SIZE as i32 + CELL_SIZE as i32 / 2 }
|
||||
|
||||
#[derive(Clone)]
|
||||
struct WeatherZone {
|
||||
@ -49,7 +49,7 @@ impl WeatherSim {
|
||||
}
|
||||
}
|
||||
let average_humid = humid_sum / (CHUNKS_PER_CELL * CHUNKS_PER_CELL) as f32;
|
||||
let rain_factor = (2.0 * average_humid.powf(0.2)).min(1.0);
|
||||
let rain_factor = (4.0 * average_humid.powf(0.2)).min(1.0);
|
||||
CellConsts { rain_factor }
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@ -82,7 +82,7 @@ impl WeatherSim {
|
||||
}
|
||||
|
||||
// Time step is cell size / maximum wind speed
|
||||
pub fn tick(&mut self, time_of_day: &TimeOfDay, out: &mut WeatherGrid) {
|
||||
pub fn tick(&mut self, world: &World, time_of_day: &TimeOfDay, out: &mut WeatherGrid) {
|
||||
let time = time_of_day.0;
|
||||
|
||||
let base_nz = Turbulence::new(
|
||||
@ -103,7 +103,12 @@ impl WeatherSim {
|
||||
self.zones[point] = None;
|
||||
}
|
||||
} else {
|
||||
let wpos = cell_to_wpos(point);
|
||||
let wpos = cell_to_wpos_center(point);
|
||||
|
||||
let humid = world
|
||||
.sim()
|
||||
.get_wpos(wpos)
|
||||
.map_or(1.0, |c| c.get_environment().humid);
|
||||
|
||||
let pos = wpos.as_::<f64>() + time as f64 * 0.1;
|
||||
|
||||
@ -112,10 +117,11 @@ impl WeatherSim {
|
||||
let spos = (pos / space_scale).with_z(time as f64 / time_scale);
|
||||
|
||||
let pressure =
|
||||
(base_nz.get(spos.into_array()) * 0.5 + 1.0).clamped(0.0, 1.0) as f32;
|
||||
(base_nz.get(spos.into_array()) * 0.5 + 1.0).clamped(0.0, 1.0) as f32 + 0.4
|
||||
- humid * 0.5;
|
||||
|
||||
const RAIN_CLOUD_THRESHOLD: f32 = 0.26;
|
||||
cell.cloud = (1.0 - pressure) * 0.5;
|
||||
const RAIN_CLOUD_THRESHOLD: f32 = 0.2;
|
||||
cell.cloud = (1.0 - pressure).max(0.0) * 0.5;
|
||||
cell.rain = (1.0 - pressure - RAIN_CLOUD_THRESHOLD).max(0.0)
|
||||
* self.consts[point].rain_factor;
|
||||
cell.wind = Vec2::new(
|
||||
|
@ -1,6 +1,7 @@
|
||||
use common::{resources::TimeOfDay, weather::WeatherGrid};
|
||||
use common_ecs::{Origin, Phase, System};
|
||||
use specs::{Read, Write, WriteExpect};
|
||||
use specs::{Read, ReadExpect, Write, WriteExpect};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::sys::SysScheduler;
|
||||
|
||||
@ -12,6 +13,7 @@ pub struct Sys;
|
||||
impl<'a> System<'a> for Sys {
|
||||
type SystemData = (
|
||||
Read<'a, TimeOfDay>,
|
||||
ReadExpect<'a, Arc<world::World>>,
|
||||
WriteExpect<'a, WeatherSim>,
|
||||
WriteExpect<'a, WeatherGrid>,
|
||||
Write<'a, SysScheduler<Self>>,
|
||||
@ -23,13 +25,13 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
fn run(
|
||||
_job: &mut common_ecs::Job<Self>,
|
||||
(game_time, mut sim, mut grid, mut scheduler): Self::SystemData,
|
||||
(game_time, world, mut sim, mut grid, mut scheduler): Self::SystemData,
|
||||
) {
|
||||
if scheduler.should_run() {
|
||||
if grid.size() != sim.size() {
|
||||
*grid = WeatherGrid::new(sim.size());
|
||||
}
|
||||
sim.tick(&game_time, &mut grid);
|
||||
sim.tick(&world, &game_time, &mut grid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user