From 5d4079b165513fe411bfe940f496dab61ab2c5ca Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 16 Aug 2019 11:31:51 +0100 Subject: [PATCH] Better reflection calculations --- assets/voxygen/shaders/fluid-frag.glsl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/voxygen/shaders/fluid-frag.glsl b/assets/voxygen/shaders/fluid-frag.glsl index b3bdd52292..fab8149bc6 100644 --- a/assets/voxygen/shaders/fluid-frag.glsl +++ b/assets/voxygen/shaders/fluid-frag.glsl @@ -26,10 +26,12 @@ void main() { float fog_level = fog(f_pos.xy, focus_pos.xy); vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x); - vec3 warped_norm = normalize(f_norm + smooth_rand(f_pos * 0.6, tick.x) * 0.75); - vec3 reflect_color = get_sky_color(reflect(normalize(f_pos - cam_pos.xyz), warped_norm), time_of_day.x); + vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); + vec3 warped_norm = normalize(f_norm + smooth_rand(f_pos * 0.35, tick.x) * 0.2); + vec3 reflect_color = get_sky_color(reflect(cam_to_frag, warped_norm), time_of_day.x); + float passthrough = max(dot(f_norm, -cam_to_frag), 0.0); - vec3 color = mix(surf_color + reflect_color * 0.5, fog_color, fog_level); + vec4 color = mix(vec4(reflect_color, 1.0), vec4(surf_color, f_opac), passthrough); - tgt_color = vec4(color, f_opac); + tgt_color = mix(color, vec4(fog_color, 1.0), fog_level); }