From 6c31e6b56217274285b597af297036691ea5d897 Mon Sep 17 00:00:00 2001 From: Joshua Yanovski Date: Sun, 12 Jul 2020 19:50:26 +0200 Subject: [PATCH] Fix shadow creation. --- assets/voxygen/shaders/figure-frag.glsl | 2 +- assets/voxygen/shaders/include/shadows.glsl | 3 +++ assets/voxygen/shaders/skybox-frag.glsl | 4 ++-- assets/voxygen/shaders/terrain-frag.glsl | 2 +- voxygen/src/render/renderer.rs | 16 +++++++++------- voxygen/src/scene/math.rs | 6 +++--- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/assets/voxygen/shaders/figure-frag.glsl b/assets/voxygen/shaders/figure-frag.glsl index 1a9e3d211b..315807549a 100644 --- a/assets/voxygen/shaders/figure-frag.glsl +++ b/assets/voxygen/shaders/figure-frag.glsl @@ -179,7 +179,7 @@ void main() { max_light += lights_at(f_pos, f_norm, view_dir, k_a, k_d, k_s, alpha, emitted_light, reflected_light); - float ao = f_ao;//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15; + float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15; reflected_light *= ao; emitted_light *= ao; diff --git a/assets/voxygen/shaders/include/shadows.glsl b/assets/voxygen/shaders/include/shadows.glsl index 15a086ff57..3359e2e611 100644 --- a/assets/voxygen/shaders/include/shadows.glsl +++ b/assets/voxygen/shaders/include/shadows.glsl @@ -81,6 +81,9 @@ float ShadowCalculationPoint(uint lightIndex, vec3 fragToLight, vec3 fragNorm, / if (visibility <= 0.25) { return 0.0; } */ + /* if (visibility < 1.0) { + return 0.0; + } */ return visibility == 1.0 ? 1.0 : 0.0; } diff --git a/assets/voxygen/shaders/skybox-frag.glsl b/assets/voxygen/shaders/skybox-frag.glsl index 42a5ebafad..a39977036d 100644 --- a/assets/voxygen/shaders/skybox-frag.glsl +++ b/assets/voxygen/shaders/skybox-frag.glsl @@ -30,8 +30,8 @@ uniform u_locals { out vec4 tgt_color; void main() { - tgt_color = vec4(MU_SCATTER, 1.0); - return; + // tgt_color = vec4(MU_SCATTER, 1.0); + // return; vec4 _clouds; vec3 cam_dir = normalize(f_pos - cam_pos.xyz); diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index 5f81df8426..efbc5d4125 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -246,7 +246,7 @@ void main() { // Computing light attenuation from water. vec3 emitted_light, reflected_light; // To account for prior saturation - /*float */f_light = faces_fluid ? 1.0 : pow(f_light, 1.5); + /*float */f_light = faces_fluid ? 1.0 : f_light * sqrt(f_light); emitted_light = vec3(1.0); reflected_light = vec3(1.0); diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 3efd357e39..7f34d5dcf5 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -160,13 +160,15 @@ impl Renderer { let dims = win_color_view.get_dimensions(); let mut shader_reload_indicator = ReloadIndicator::new(); - let shadow_views = ShadowMapMode::try_from(mode.shadow).ok().and_then(|mode| { - Self::create_shadow_views(&mut factory, (dims.0, dims.1), &mode) - .map_err(|err| { - warn!("Could not create shadow map views: {:?}", err); - }) - .ok() - }); + let shadow_views = Self::create_shadow_views( + &mut factory, + (dims.0, dims.1), + &ShadowMapMode::try_from(mode.shadow).unwrap_or(ShadowMapMode::default()), + ) + .map_err(|err| { + warn!("Could not create shadow map views: {:?}", err); + }) + .ok(); let ( skybox_pipeline, diff --git a/voxygen/src/scene/math.rs b/voxygen/src/scene/math.rs index 86f504d481..2d55b5bfeb 100644 --- a/voxygen/src/scene/math.rs +++ b/voxygen/src/scene/math.rs @@ -1,9 +1,9 @@ use core::{iter, mem}; use hashbrown::HashMap; use num::traits::Float; -pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*}; -// pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, -// vec::repr_c::*}; +// pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, +// vec::repr_simd::*}; +pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, vec::repr_c::*}; pub fn aabb_to_points(bounds: Aabb) -> [Vec3; 8] { [