fixes for gles mode

This commit is contained in:
milek7
2019-09-27 13:26:00 +02:00
parent cebf5de86a
commit a3abdeac63
6 changed files with 31 additions and 19 deletions

View File

@@ -47,7 +47,7 @@ void main()
discard;
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal = normalize(f_tbn * normalize(normal.xyz));
//vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0));
vec3 refvec = reflect(f_pos.xyz, normal);

View File

@@ -54,7 +54,7 @@ void main()
discard;
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.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal_p = normalize(f_tbn * normalize(normal.xyz));
vec3 refvec = reflect(f_pos.xyz, normal_p);
#if ENVMAP_ENABLED
@@ -107,11 +107,11 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
#if ENVMAP_ENABLED
const float minLayers = 8.0;
const float maxLayers = 32.0;
float LayersWeight = 1;
if (length(f_pos.xyz) > 20)
LayersWeight = 1;
float LayersWeight = 1.0;
if (length(f_pos.xyz) > 20.0)
LayersWeight = 1.0;
else
LayersWeight = (length(f_pos.xyz) / 20);
LayersWeight = (length(f_pos.xyz) / 20.0);
vec2 currentTexCoords = f_coord;
float currentDepthMapValue = texture(normalmap, currentTexCoords).b;
LayersWeight = min(abs(dot(vec3(0.0, 0.0, 1.0), viewDir)),LayersWeight);
@@ -143,4 +143,4 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
vec2 p = viewDir.xy / viewDir.z * (height * param[2].y - param[2].z);
return f_coord - p;
#endif
}
}

View File

@@ -38,7 +38,7 @@ uniform samplerCube envmap;
#endif
//wave distortion variables
float move_factor = 0;
float move_factor = 0.0;
vec3 normal_d;
#define WATER
@@ -49,7 +49,7 @@ void main()
{
//wave distortion
move_factor += (param[2].z * time);
move_factor = mod(move_factor, 1);
move_factor = mod(move_factor, 1.0);
vec2 texture_coords = f_coord;
vec2 distorted_tex_coord = texture(dudvmap, vec2(texture_coords.x + move_factor, texture_coords.y)).rg * 0.1;
distorted_tex_coord = texture_coords + vec2(distorted_tex_coord.x , distorted_tex_coord.y + move_factor);
@@ -58,7 +58,7 @@ void main()
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.z = sqrt(1.0 - 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