Better reflection calculations

This commit is contained in:
Joshua Barretto 2019-08-16 11:31:51 +01:00
parent b5b3b980fe
commit 5d4079b165

View File

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