Fix clouds

This commit is contained in:
Imbris 2020-12-07 00:36:45 -05:00 committed by Avi Weinstock
parent 8c44fdaac2
commit 2534e65d0e
2 changed files with 9 additions and 2 deletions

View File

@ -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;

View File

@ -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