Fixed srgb normal bug

This commit is contained in:
Joshua Barretto 2019-10-17 17:35:17 +01:00
parent 04c64dc122
commit dcf8655202

View File

@ -59,11 +59,11 @@ void main() {
vec3 c_norm = cross(f_norm, b_norm);
vec3 nmap = normalize(
(texture(t_waves, fract(f_pos.xy * 0.3 + tick.x * 0.04)).rgb - 0.0) * 0.05
+ (texture(t_waves, fract(f_pos.xy * 0.1 - tick.x * 0.08)).rgb - 0.0) * 0.1
+ (texture(t_waves, fract(-f_pos.yx * 0.06 - tick.x * 0.1)).rgb - 0.0) * 0.1
+ (texture(t_waves, fract(-f_pos.yx * 0.03 - tick.x * 0.01)).rgb - 0.0) * 0.2
+ vec3(0, 0, 0.1)
(srgb_to_linear(texture(t_waves, fract(f_pos.xy * 0.3 + tick.x * 0.04)).rgb) - 0.0) * 0.05
+ (srgb_to_linear(texture(t_waves, fract(f_pos.xy * 0.1 - tick.x * 0.08)).rgb) - 0.0) * 0.1
+ (srgb_to_linear(texture(t_waves, fract(-f_pos.yx * 0.06 - tick.x * 0.1)).rgb) - 0.0) * 0.1
+ (srgb_to_linear(texture(t_waves, fract(-f_pos.yx * 0.03 - tick.x * 0.01)).rgb) - 0.0) * 0.2
+ vec3(0, 0, 0.0)
);
vec3 norm = f_norm * nmap.z + b_norm * nmap.x + c_norm * nmap.y;
@ -89,9 +89,9 @@ void main() {
vec3 reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, false) * f_light;
//reflect_color = vec3(reflect_color.r + reflect_color.g + reflect_color.b) / 3.0;
// 0 = 100% reflection, 1 = translucent water
float passthrough = pow(dot(faceforward(norm, norm, cam_to_frag), -cam_to_frag), 0.5);
float passthrough = pow(dot(faceforward(f_norm, f_norm, cam_to_frag), -cam_to_frag), 0.3);
vec4 color = mix(vec4(reflect_color, 1.0), vec4(surf_color, 4.0 / (1.0 + diffuse_light * 2.0)), passthrough);
vec4 color = mix(vec4(reflect_color * 2.0, 1.0), vec4(surf_color, 4.0 / (1.0 + diffuse_light * 2.0)), passthrough);
tgt_color = mix(color, vec4(fog_color, 0.0), fog_level);
}