From 83dc22dfbf264588bc1049688e4470481f37d1c9 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 22 Oct 2023 18:21:25 +0100 Subject: [PATCH] Made ice reflective --- assets/voxygen/shaders/clouds-frag.glsl | 6 +++++- assets/voxygen/shaders/include/constants.glsl | 1 + assets/voxygen/shaders/rope-frag.glsl | 2 +- assets/voxygen/shaders/rope-vert.glsl | 2 +- assets/voxygen/shaders/terrain-frag.glsl | 11 ++++++++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 21fdbc60fb..2ea6e1f3af 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -128,7 +128,11 @@ void main() { // vec3 surf_norm = normalize(vec3(nz * 0.03 / (1.0 + dist * 0.1), 1)); // refr_dir = refract(dir, surf_norm * -sign(dir.z), 1.0 / n2); // } else { - refr_dir = normalize(dir + vec3(nz * 1.5 / dist, 0.0)); + if (mat.a == MAT_FLUID) { + refr_dir = normalize(dir + vec3(nz * 1.5 / dist, 0.0)); + } else { + refr_dir = dir; + } // } vec4 clip = (all_mat * vec4(cam_pos.xyz + refr_dir, 1.0)); diff --git a/assets/voxygen/shaders/include/constants.glsl b/assets/voxygen/shaders/include/constants.glsl index 2ffb537df6..e1f4c01884 100644 --- a/assets/voxygen/shaders/include/constants.glsl +++ b/assets/voxygen/shaders/include/constants.glsl @@ -60,6 +60,7 @@ #define BLOCK_SNOW 0x21 #define BLOCK_ART_SNOW 0x22 +#define BLOCK_ICE 0x43 // An arbitrary value that represents a very far distance (at least as far as the player should be able to see) without // being too far that we end up with precision issues (used in clouds and elsewhere). diff --git a/assets/voxygen/shaders/rope-frag.glsl b/assets/voxygen/shaders/rope-frag.glsl index d7cc9e487c..65779f060d 100644 --- a/assets/voxygen/shaders/rope-frag.glsl +++ b/assets/voxygen/shaders/rope-frag.glsl @@ -1,4 +1,4 @@ -#version 420 core +#version 430 core #define FIGURE_SHADER diff --git a/assets/voxygen/shaders/rope-vert.glsl b/assets/voxygen/shaders/rope-vert.glsl index d01917b1b3..01859636fe 100644 --- a/assets/voxygen/shaders/rope-vert.glsl +++ b/assets/voxygen/shaders/rope-vert.glsl @@ -1,4 +1,4 @@ -#version 420 core +#version 430 core #include diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index e5a0af2277..0176e41f56 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -93,6 +93,8 @@ void main() { uint f_kind; vec3 f_col = greedy_extract_col_light_kind_terrain(t_col_light, s_col_light, t_kind, f_uv_pos, f_light, f_glow, f_ao, f_sky_exposure, f_kind); + uint f_mat = MAT_BLOCK; + #ifdef EXPERIMENTAL_BAREMINIMUM tgt_color = vec4(simple_lighting(f_pos.xyz, f_col, f_light), 1); return; @@ -280,6 +282,7 @@ void main() { alpha = mix(1.0, 0.2, puddle); f_col.rgb *= mix(1.0, 0.7, puddle); k_s = mix(k_s, vec3(0.7, 0.7, 1.0), puddle); + f_mat = MAT_FLUID; } #endif @@ -306,6 +309,12 @@ void main() { } #endif + // Reflections on ice + if (f_kind == BLOCK_ICE && f_norm.z == 1.0) { + f_alpha = min(f_alpha, 0.3); + k_s = mix(k_s, vec3(0.7, 0.7, 1.0), 0.5); + } + // float sun_light = get_sun_brightness(sun_dir); // float moon_light = get_moon_brightness(moon_dir); /* float sun_shade_frac = horizon_at(f_pos, sun_dir); @@ -559,6 +568,6 @@ void main() { surf_color += f_select * (surf_color + 0.1) * vec3(0.5, 0.5, 0.5); tgt_color = vec4(surf_color, f_alpha); - tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), MAT_BLOCK); + tgt_mat = uvec4(uvec3((f_norm + 1.0) * 127.0), f_mat); //tgt_color = vec4(f_norm, f_alpha); }