From 905a164c0cb5e7c375701780936409ab8a47fa1c Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 21 Apr 2021 21:20:04 -0400 Subject: [PATCH] Comment out lod depth tweaks not designed for reverse depth, convert waves image to rgba before constructing a texture, misc fix after rebase --- assets/voxygen/shaders/include/cloud/regular.glsl | 2 +- assets/voxygen/shaders/lod-terrain-vert.glsl | 11 ++++++++--- voxygen/src/scene/terrain.rs | 9 ++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/assets/voxygen/shaders/include/cloud/regular.glsl b/assets/voxygen/shaders/include/cloud/regular.glsl index 063275790d..786f3a7973 100644 --- a/assets/voxygen/shaders/include/cloud/regular.glsl +++ b/assets/voxygen/shaders/include/cloud/regular.glsl @@ -136,7 +136,7 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) { #if (CLOUD_MODE >= CLOUD_MODE_MEDIUM) emission_alt += (noise_3d(vec3(wind_pos.xy * 0.0005 + cloud_tendency * 0.2, emission_alt * 0.0001 + time_of_day.x * 0.001)) - 0.5) * 1000; #endif - float tail = (textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00005).x - 0.5, 0) * 4 + (pos.z - emission_alt) * 0.0001; + float tail = (textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00005, 0).x - 0.5, 0) * 4 + (pos.z - emission_alt) * 0.0001; vec3 emission_col = vec3(0.8 + tail * 1.5, 0.5 - tail * 0.2, 0.3 + tail * 0.2); float emission_nz = max(pow(textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.000015, 0).x, 8), 0.01) * 0.25 / (10.0 + abs(pos.z - emission_alt) / 80); emission = emission_col * emission_nz * emission_strength * max(sun_dir.z, 0) * 500000 / (1000.0 + abs(pos.z - emission_alt) * 0.1); diff --git a/assets/voxygen/shaders/lod-terrain-vert.glsl b/assets/voxygen/shaders/lod-terrain-vert.glsl index 48e04efb9f..48554ea74e 100644 --- a/assets/voxygen/shaders/lod-terrain-vert.glsl +++ b/assets/voxygen/shaders/lod-terrain-vert.glsl @@ -44,8 +44,11 @@ void main() { // f_shadow = textureBicubic(t_horizon, pos_to_tex(f_pos.xy)); - float dist = distance(focus_pos.xy, f_pos.xy); - pull_down = 0.2 / pow(dist / (view_distance.x * 0.9), 20.0); + // TODO: disabled because it isn't designed to work with reverse depth + //float dist = distance(focus_pos.xy, f_pos.xy); + //pull_down = 0.2 / pow(dist / (view_distance.x * 0.9), 20.0); + + pull_down = 1.0 / pow(distance(focus_pos.xy, f_pos.xy) / (view_distance.x * 0.95), 20.0); f_pos.z -= pull_down; // f_pos.z -= 100.0 * pow(1.0 + 0.01 / view_distance.x, -pow(distance(focus_pos.xy, f_pos.xy), 2.0)); @@ -95,7 +98,9 @@ void main() { all_mat * vec4(f_pos/*newRay*/, 1); // Pull up the depth to avoid drawing over voxels (biased according to VD) - gl_Position.z += 0.1 * clamp((view_distance.x * 1.0 - dist) * 0.01, 0, 1); + // TODO: disabled because it isn't designed to work with reverse depth + //gl_Position.z += 0.1 * clamp((view_distance.x * 1.0 - dist) * 0.01, 0, 1); + // gl_Position.z = -gl_Position.z / gl_Position.w; // gl_Position.z = -gl_Position.z / gl_Position.w; // gl_Position.z = -gl_Position.z * gl_Position.w; diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 741e075fe5..9f447918bc 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -568,7 +568,14 @@ impl Terrain { waves: { let waves_tex = renderer .create_texture( - &assets::Image::load_expect("voxygen.texture.waves").read().0, + // TODO: actually this is unused, remove? + // TODO: re-add alpha channel? + &image::DynamicImage::ImageRgba8( + assets::Image::load_expect("voxygen.texture.waves") + .read() + .0 + .to_rgba8(), + ), Some(wgpu::FilterMode::Linear), Some(wgpu::AddressMode::Repeat), )