From 745e7540ddb000cc645f612767b337c2ddc3f7c0 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 22 Nov 2019 12:40:48 +0000 Subject: [PATCH] Improved cloud falloff mist, faster noise sampling --- assets/voxygen/shaders/include/lod.glsl | 2 +- assets/voxygen/shaders/include/sky.glsl | 9 +++++---- assets/voxygen/shaders/lod-terrain-frag.glsl | 2 +- assets/voxygen/shaders/terrain-frag.glsl | 2 +- voxygen/src/render/renderer.rs | 2 +- voxygen/src/scene/terrain.rs | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/assets/voxygen/shaders/include/lod.glsl b/assets/voxygen/shaders/include/lod.glsl index 6e8af1dee8..db9fed1f98 100644 --- a/assets/voxygen/shaders/include/lod.glsl +++ b/assets/voxygen/shaders/include/lod.glsl @@ -12,7 +12,7 @@ vec2 splay(vec2 pos, float e) { } vec3 lod_pos(vec2 v_pos) { - vec2 hpos = focus_pos.xy + splay(v_pos, 3.0) * 20000.0; + vec2 hpos = focus_pos.xy + splay(v_pos, 4.0) * 100000.0; return vec3(hpos, alt_at(hpos)); } diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 1e1c104130..5c11207d22 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -132,7 +132,7 @@ vec2 cloud_at(vec3 pos) { float shade = ((pos.z - CLOUD_AVG_HEIGHT) / (CLOUD_AVG_HEIGHT - CLOUD_HEIGHT_MIN) + 0.5); - return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 5000)); + return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 10000)); } vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) { @@ -143,7 +143,8 @@ vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, f float maxd = (CLOUD_HEIGHT_MAX - origin.z) / dir.z; float start = max(min(mind, maxd), 0.0); - float delta = min(abs(mind - maxd), max_dist); + float cloud_delta = abs(mind - maxd); + float delta = min(cloud_delta, max_dist); bool do_cast = true; if (mind < 0.0 && maxd < 0.0) { @@ -170,7 +171,7 @@ vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, f } } - float total_density = 1.0 - passthrough;// / (1.0 + max(max_dist, start) * 0.0001); + float total_density = 1.0 - passthrough / (1.0 + (max_dist / (1.0 + max(abs(dir.z), 0.03) * 100.0)) * 0.00003); total_density = max(total_density - 1.0 / pow(max_dist, 0.25), 0.0); // Hack @@ -267,7 +268,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q } float fog(vec3 f_pos, vec3 focus_pos, uint medium) { - return max(1.0 - 10000.0 / (1.0 + distance(f_pos.xy, focus_pos.xy)), 0.0); + return max(1.0 - 5000.0 / (1.0 + distance(f_pos.xy, focus_pos.xy)), 0.0); float fog_radius = view_distance.x; float mist_radius = 10000000.0; diff --git a/assets/voxygen/shaders/lod-terrain-frag.glsl b/assets/voxygen/shaders/lod-terrain-frag.glsl index 1481b8b189..bf53fe3297 100644 --- a/assets/voxygen/shaders/lod-terrain-frag.glsl +++ b/assets/voxygen/shaders/lod-terrain-frag.glsl @@ -23,7 +23,7 @@ void main() { float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); vec4 clouds; vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, cam_pos.xyz, f_pos, 1.0, true, clouds); - vec3 color = mix(mix(surf_color, vec3(1), fog_level), clouds.rgb, clouds.a); + vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a); tgt_color = vec4(color, 1.0); } diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index 263b9c0c46..b6a17e48f2 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -36,7 +36,7 @@ void main() { float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); vec4 clouds; vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, cam_pos.xyz, f_pos, 1.0, true, clouds); - vec3 color = mix(mix(surf_color, vec3(1), fog_level), clouds.rgb, clouds.a); + vec3 color = mix(mix(surf_color, fog_color, fog_level), clouds.rgb, clouds.a); tgt_color = vec4(color, 1.0); } diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index d50003b724..8081d42792 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -124,7 +124,7 @@ impl Renderer { let noise_tex = Texture::new( &mut factory, &assets::load_expect("voxygen.texture.noise"), - Some(gfx::texture::FilterMethod::Trilinear), + Some(gfx::texture::FilterMethod::Bilinear), Some(gfx::texture::WrapMode::Tile), )?; diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index c6c41f4928..f4eae9911e 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -1240,7 +1240,7 @@ impl Terrain { // a sample of the terrain that includes both the chunk we want and // its neighbours. let volume = match client.state().terrain().sample(aabr) { - Ok(sample) => sample, + Ok(sample) => sample, // TODO: Ensure that all of the chunk's neighbours still exist to avoid buggy shadow borders // Either this chunk or its neighbours doesn't yet exist, so we keep it in the // queue to be processed at a later date when we have its neighbours. Err(VolGrid2dError::NoSuchChunk) => return,