From 2534e65d0edd57d3acff58ef18bd27aabb7a8422 Mon Sep 17 00:00:00 2001 From: Imbris Date: Mon, 7 Dec 2020 00:36:45 -0500 Subject: [PATCH] Fix clouds --- assets/voxygen/shaders/include/lod.glsl | 5 +++-- voxygen/src/render/pipelines/mod.rs | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/shaders/include/lod.glsl b/assets/voxygen/shaders/include/lod.glsl index a14170a536..9b472b6074 100644 --- a/assets/voxygen/shaders/include/lod.glsl +++ b/assets/voxygen/shaders/include/lod.glsl @@ -121,8 +121,10 @@ vec4 utextureBicubic(utexture2D tex, sampler sampl, vec2 texCoords) { , sy); } +const float U16_MAX = 65535.0; + float alt_at(vec2 pos) { - return (/*round*/(texture/*textureBicubic*/(usampler2D(t_alt, s_alt), pos_to_uv(t_alt, s_alt, pos)).r * (/*1300.0*//*1278.7266845703125*/view_distance.w)) + /*140.0*/view_distance.z - focus_off.z); + return (/*round*/(texture/*textureBicubic*/(usampler2D(t_alt, s_alt), pos_to_uv(t_alt, s_alt, pos)).r / U16_MAX * (/*1300.0*//*1278.7266845703125*/view_distance.w)) + /*140.0*/view_distance.z - focus_off.z); //+ (texture(t_noise, pos * 0.002).x - 0.5) * 64.0; // return 0.0 @@ -136,7 +138,6 @@ float alt_at_real(vec2 pos) { // #if (FLUID_MODE == FLUID_MODE_CHEAP) // return alt_at(pos); // #elif (FLUID_MODE == FLUID_MODE_SHINY) - const float U16_MAX = 65535.0; return (/*round*/(utextureBicubic(t_alt, s_alt, pos_to_tex(pos)).r / U16_MAX * (/*1300.0*//*1278.7266845703125*/view_distance.w)) + /*140.0*/view_distance.z - focus_off.z); // #endif //+ (texture(t_noise, pos * 0.002).x - 0.5) * 64.0; diff --git a/voxygen/src/render/pipelines/mod.rs b/voxygen/src/render/pipelines/mod.rs index 4f6d2bf7eb..05f07c80f8 100644 --- a/voxygen/src/render/pipelines/mod.rs +++ b/voxygen/src/render/pipelines/mod.rs @@ -24,11 +24,17 @@ pub const MAX_DIRECTED_LIGHT_COUNT: usize = 6; #[repr(C)] #[derive(Copy, Clone, Debug, Zeroable, Pod)] pub struct Globals { + /// Transformation from world coordinate space (with focus_off as the + /// origin) to the camera space view_mat: [[f32; 4]; 4], proj_mat: [[f32; 4]; 4], + /// proj_mat * view_mat all_mat: [[f32; 4]; 4], + /// Offset of the camera from the focus position cam_pos: [f32; 4], + /// Integer portion of the focus position in world coordinates focus_off: [f32; 4], + /// Fractions portion of the focus position focus_pos: [f32; 4], /// NOTE: view_distance.x is the horizontal view distance, view_distance.y /// is the LOD detail, view_distance.z is the