Z-normal reconstruction for water shader.

This commit is contained in:
stele
2019-05-03 17:48:42 +02:00
parent 410e1452f6
commit 934044e0a9
2 changed files with 5 additions and 2 deletions

View File

@@ -52,7 +52,7 @@ void main()
if (tex_color.a < opacity)
discard;
vec3 normal = f_normal;
vec3 normal;
normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0);
normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal_p = normalize(f_tbn * normalize(normal.xyz));

View File

@@ -56,7 +56,10 @@ void main()
vec2 total_distorted_tex_coord = (texture(dudvmap, distorted_tex_coord).rg * 2.0 - 1.0 ) * param[2].y;
texture_coords += total_distorted_tex_coord;
normal_d = f_tbn * normalize(texture(normalmap, texture_coords).rgb * 2.0 - 1.0);
vec3 normal;
normal.xy = (texture(normalmap, texture_coords).rg * 2.0 - 1.0);
normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal_d = normalize(f_tbn * normalize(normal.xyz));
vec3 refvec = reflect(f_pos.xyz, normal_d);
#if ENVMAP_ENABLED
vec3 envcolor = texture(envmap, refvec).rgb;