mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'isse/small-fixes' into 'master'
Client local time, used for fluid shaders See merge request veloren/veloren!4128
This commit is contained in:
commit
e0c67c470b
@ -52,22 +52,22 @@ layout(location = 1) out uvec4 tgt_mat;
|
||||
#include <light.glsl>
|
||||
#include <lod.glsl>
|
||||
|
||||
vec4 water_col(vec2 pos) {
|
||||
pos += focus_off.xy;
|
||||
pos *= 0.1;
|
||||
vec2 v = floor(f_vel) * 0.1;
|
||||
vec4 uv = tick_loop4(1, -v.xxyy - vec2(0, 0.1).xyxy, pos.xxyy);
|
||||
|
||||
vec4 water_col(vec4 posx, vec4 posy) {
|
||||
posx = (posx + focus_off.x) * 0.1;
|
||||
posy = (posy + focus_off.y) * 0.1;
|
||||
return 0.5 + (vec4(
|
||||
textureLod(sampler2D(t_noise, s_noise), uv.xz, 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), uv.yz, 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), uv.xw, 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), uv.yw, 0).x
|
||||
textureLod(sampler2D(t_noise, s_noise), vec2(posx.x, posy.x), 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), vec2(posx.y, posy.y), 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), vec2(posx.z, posy.z), 0).x,
|
||||
textureLod(sampler2D(t_noise, s_noise), vec2(posx.w, posy.w), 0).x
|
||||
) - 0.5) * 1.0;
|
||||
}
|
||||
|
||||
float water_col_vel(vec2 pos){
|
||||
vec4 cols = water_col(pos);
|
||||
vec4 cols = water_col(
|
||||
pos.x - tick.z * floor(f_vel.x) - vec2(0.0, tick.z).xyxy,
|
||||
pos.y - tick.z * floor(f_vel.y) - vec2(0.0, tick.z).xxyy
|
||||
);
|
||||
return mix(
|
||||
mix(cols.x, cols.y, fract(f_vel.x + 1.0)),
|
||||
mix(cols.z, cols.w, fract(f_vel.x + 1.0)),
|
||||
|
@ -54,16 +54,13 @@ layout(location = 1) out uvec4 tgt_mat;
|
||||
#include <light.glsl>
|
||||
#include <lod.glsl>
|
||||
|
||||
void wave_dx(vec2 pos, vec2 dir, float speed, float frequency, float factor, vec4 accumx, vec4 accumy, out vec4 wave, out vec4 dx) {
|
||||
float ff = frequency * factor;
|
||||
|
||||
vec2 v = floor(f_vel);
|
||||
vec4 kx = (v.x + vec2(0, 1)).xyxy;
|
||||
vec4 ky = (v.y + vec2(0, 1)).xxyy;
|
||||
vec4 p = speed - ff * (dir.x * kx + dir.y * ky);
|
||||
vec4 q = frequency * ((dir.x * factor * pos.x + accumx) + dir.y * (factor * pos.y + accumy));
|
||||
vec4 x = tick_loop4(2 * PI, p, q);
|
||||
|
||||
void wave_dx(vec4 posx, vec4 posy, vec2 dir, float speed, float frequency, float timeshift, out vec4 wave, out vec4 dx) {
|
||||
vec4 x = vec4(
|
||||
dot(dir, vec2(posx.x, posy.x)),
|
||||
dot(dir, vec2(posx.y, posy.y)),
|
||||
dot(dir, vec2(posx.z, posy.z)),
|
||||
dot(dir, vec2(posx.w, posy.w))
|
||||
) * frequency + timeshift * speed;
|
||||
wave = sin(x) + 0.5;
|
||||
wave *= wave;
|
||||
dx = -wave * cos(x);
|
||||
@ -73,7 +70,7 @@ void wave_dx(vec2 pos, vec2 dir, float speed, float frequency, float factor, vec
|
||||
// Modified to allow calculating the wave function 4 times at once using different positions (used for intepolation
|
||||
// for moving water). The general idea is to sample the wave function at different positions, where those positions
|
||||
// depend on increments of the velocity, and then interpolate between those velocities to get a smooth water velocity.
|
||||
vec4 wave_height(vec2 pos) {
|
||||
vec4 wave_height(vec4 posx, vec4 posy) {
|
||||
float iter = 0.0;
|
||||
float phase = 4.0;
|
||||
float weight = 1.5;
|
||||
@ -82,28 +79,27 @@ vec4 wave_height(vec2 pos) {
|
||||
const float speed_per_iter = 0.1;
|
||||
#if (FLUID_MODE == FLUID_MODE_HIGH)
|
||||
float speed = 1.0;
|
||||
const float factor = 0.2;
|
||||
posx *= 0.2;
|
||||
posy *= 0.2;
|
||||
const float drag_factor = 0.035;
|
||||
const int iters = 21;
|
||||
const float scale = 15.0;
|
||||
#else
|
||||
float speed = 2.0;
|
||||
const float factor = 0.3;
|
||||
posx *= 0.3;
|
||||
posy *= 0.3;
|
||||
const float drag_factor = 0.04;
|
||||
const int iters = 11;
|
||||
const float scale = 3.0;
|
||||
#endif
|
||||
const float iter_shift = (3.14159 * 2.0) / 7.3;
|
||||
|
||||
vec4 accumx = vec4(0);
|
||||
vec4 accumy = vec4(0);
|
||||
|
||||
for(int i = 0; i < iters; i ++) {
|
||||
vec2 p = vec2(sin(iter), cos(iter));
|
||||
vec4 wave, dx;
|
||||
wave_dx(pos, p, speed, phase, factor, accumx, accumy, wave, dx);
|
||||
accumx += p.x * dx * weight * drag_factor;
|
||||
accumy += p.y * dx * weight * drag_factor;
|
||||
wave_dx(posx, posy, p, speed, phase, tick.z, wave, dx);
|
||||
posx += p.x * dx * weight * drag_factor;
|
||||
posy += p.y * dx * weight * drag_factor;
|
||||
w += wave * weight;
|
||||
iter += iter_shift * 1.5;
|
||||
ws += weight;
|
||||
@ -115,7 +111,10 @@ vec4 wave_height(vec2 pos) {
|
||||
}
|
||||
|
||||
float wave_height_vel(vec2 pos) {
|
||||
vec4 heights = wave_height(pos);
|
||||
vec4 heights = wave_height(
|
||||
pos.x - tick.z * floor(f_vel.x) - vec2(0.0, tick.z).xyxy,
|
||||
pos.y - tick.z * floor(f_vel.y) - vec2(0.0, tick.z).xxyy
|
||||
);
|
||||
return mix(
|
||||
mix(heights.x, heights.y, fract(f_vel.x + 1.0)),
|
||||
mix(heights.z, heights.w, fract(f_vel.x + 1.0)),
|
||||
@ -276,7 +275,7 @@ void main() {
|
||||
/* reflect_color = get_cloud_color(reflect_color, ray_dir, f_pos.xyz, time_of_day.x, 100000.0, 0.1); */
|
||||
reflect_color = vec3(0);
|
||||
#else
|
||||
reflect_color = get_sky_color(ray_dir, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac);
|
||||
reflect_color = get_sky_color(ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true, 1.0, true, sun_shade_frac);
|
||||
#endif
|
||||
// Sort of non-physical, but we try to balance the reflection intensity with the direct light from the sun,
|
||||
// resulting in decent reflection of the ambient environment even after the sun has gone down.
|
||||
@ -340,7 +339,7 @@ void main() {
|
||||
float passthrough = max(dot(cam_norm, -cam_to_frag), 0) * 0.75;
|
||||
|
||||
float max_light = 0.0;
|
||||
max_light += get_sun_diffuse2(sun_info, moon_info, cam_norm, sun_view_dir, f_pos, mu, cam_attenuation, fluid_alt, k_a/* * (shade_frac * 0.5 + light_frac * 0.5)*/, vec3(k_d), /*vec3(f_light * point_shadow)*//*reflect_color*/k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
max_light += get_sun_diffuse2(sun_info, moon_info, cam_norm, /*time_of_day.x*/sun_view_dir, f_pos, mu, cam_attenuation, fluid_alt, k_a/* * (shade_frac * 0.5 + light_frac * 0.5)*/, vec3(k_d), /*vec3(f_light * point_shadow)*//*reflect_color*/k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
|
||||
emitted_light *= not_underground;
|
||||
reflected_light *= not_underground;
|
||||
|
||||
|
@ -16,7 +16,7 @@ layout(std140, set = 0, binding = 0) uniform u_globals {
|
||||
vec4 moon_dir;
|
||||
// .x = The `Time` resource, repeated every `tick_overflow`
|
||||
// .y = a floored (`Time` / `tick_overflow`)
|
||||
// .z = `Time`, not recommended to be used as it might have low precision
|
||||
// .z = Time local to client, not synced between clients.
|
||||
vec4 tick;
|
||||
vec4 screen_res;
|
||||
uvec4 light_shadow_count;
|
||||
|
@ -21,6 +21,7 @@ use common::comp;
|
||||
use common_base::span;
|
||||
use i18n::LocalizationHandle;
|
||||
use scene::Scene;
|
||||
#[cfg(feature = "singleplayer")]
|
||||
use server::ServerInitStage;
|
||||
use std::sync::Arc;
|
||||
use tokio::runtime;
|
||||
@ -29,7 +30,9 @@ use ui::{Event as MainMenuEvent, MainMenuUi};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DetailedInitializationStage {
|
||||
#[cfg(feature = "singleplayer")]
|
||||
Singleplayer,
|
||||
#[cfg(feature = "singleplayer")]
|
||||
SingleplayerServer(ServerInitStage),
|
||||
StartingMultiplayer,
|
||||
Client(ClientInitStage),
|
||||
|
@ -16,6 +16,7 @@ use i18n::Localization;
|
||||
use iced::{button, Align, Column, Container, Length, Row, Space, Text};
|
||||
use keyboard_keynames::key_layout::KeyLayout;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "singleplayer")]
|
||||
use server::{ServerInitStage, WorldCivStage, WorldGenerateStage, WorldSimStage};
|
||||
|
||||
struct LoadingAnimation {
|
||||
@ -139,9 +140,11 @@ impl Screen {
|
||||
|
||||
let stage = {
|
||||
let stage_message = match init_stage {
|
||||
#[cfg(feature = "singleplayer")]
|
||||
DetailedInitializationStage::Singleplayer => {
|
||||
i18n.get_msg("hud-init-stage-singleplayer")
|
||||
},
|
||||
#[cfg(feature = "singleplayer")]
|
||||
DetailedInitializationStage::SingleplayerServer(server_stage) => {
|
||||
match server_stage {
|
||||
ServerInitStage::DbMigrations => {
|
||||
|
@ -106,6 +106,7 @@ impl Globals {
|
||||
map_bounds: Vec2<f32>,
|
||||
time_of_day: f64,
|
||||
tick: f64,
|
||||
client_tick: f64,
|
||||
screen_res: Vec2<u16>,
|
||||
shadow_planes: Vec2<f32>,
|
||||
light_count: usize,
|
||||
@ -147,7 +148,7 @@ impl Globals {
|
||||
tick: [
|
||||
(tick % TIME_OVERFLOW) as f32,
|
||||
(tick / TIME_OVERFLOW).floor() as f32,
|
||||
tick as f32,
|
||||
client_tick as f32,
|
||||
0.0,
|
||||
],
|
||||
// Provide the shadow map far plane as well.
|
||||
@ -224,6 +225,7 @@ impl Default for Globals {
|
||||
Vec2::new(140.0, 2048.0),
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
Vec2::new(800, 500),
|
||||
Vec2::new(1.0, 25.0),
|
||||
0,
|
||||
|
@ -33,7 +33,7 @@ use common::{
|
||||
calendar::Calendar,
|
||||
comp::{self, ship::figuredata::VOXEL_COLLIDER_MANIFEST},
|
||||
outcome::Outcome,
|
||||
resources::DeltaTime,
|
||||
resources::{DeltaTime, TimeScale},
|
||||
terrain::{BlockKind, TerrainChunk, TerrainGrid},
|
||||
vol::ReadVol,
|
||||
};
|
||||
@ -113,6 +113,7 @@ pub struct Scene {
|
||||
wind_vel: Vec2<f32>,
|
||||
pub interpolated_time_of_day: Option<f64>,
|
||||
last_lightning: Option<(Vec3<f32>, f64)>,
|
||||
local_time: f64,
|
||||
}
|
||||
|
||||
pub struct SceneData<'a> {
|
||||
@ -348,6 +349,7 @@ impl Scene {
|
||||
wind_vel: Vec2::zero(),
|
||||
interpolated_time_of_day: None,
|
||||
last_lightning: None,
|
||||
local_time: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,6 +525,8 @@ impl Scene {
|
||||
|
||||
let dt = ecs.fetch::<DeltaTime>().0;
|
||||
|
||||
self.local_time += dt as f64 * ecs.fetch::<TimeScale>().0;
|
||||
|
||||
let positions = ecs.read_storage::<comp::Pos>();
|
||||
|
||||
let viewpoint_pos = if let Some(viewpoint_pos) =
|
||||
@ -846,6 +850,7 @@ impl Scene {
|
||||
self.map_bounds,
|
||||
time_of_day,
|
||||
scene_data.state.get_time(),
|
||||
self.local_time,
|
||||
renderer.resolution().as_(),
|
||||
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
||||
lights.len(),
|
||||
|
@ -272,6 +272,7 @@ impl Scene {
|
||||
self.map_bounds,
|
||||
TIME,
|
||||
scene_data.time,
|
||||
0.0,
|
||||
renderer.resolution().as_(),
|
||||
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
||||
0,
|
||||
|
Loading…
Reference in New Issue
Block a user