Made ice reflective

This commit is contained in:
Joshua Barretto 2023-10-22 18:21:25 +01:00 committed by Christof Petig
parent 05863eb1ef
commit 83dc22dfbf
5 changed files with 18 additions and 4 deletions

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#version 420 core
#version 430 core
#define FIGURE_SHADER

View File

@ -1,4 +1,4 @@
#version 420 core
#version 430 core
#include <constants.glsl>

View File

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