// Oh and this is how I compute the clipSpace in the vertex shader: clipSpace = mvp * a_position;
vec2 ndc = (clipSpace.xy/clipSpace.w) / 2.0 + 0.5;
vec2 reflectionTexCoords = vec2(ndc.x, -ndc.y);
vec2 refractionTexCoords = vec2(ndc.x, ndc.y);
vec4 distortion1 = (texture2D(dudv, vec2(newTexCoords.x + moveFactor, newTexCoords.y).rg * 2.0 - 1.0)) * waveStr;
vec4 distortion2 = (texture2D(dudv, vec2(-newTexCoords.x + moveFactor, newTexCoords.y + moveFactor).rg * 2.0 - 1.0)) * waveStr;
vec4 totalDistortion = distortion1 + distortion2;
refractionTexCoords += totalDistortion.xy;
refractionTexCoords = clamp(refractionTexCoords, 0.001, 0.999);
reflectionTexCoords += totalDistortion.xy;
reflectionTexCoords.x = clamp(reflectionTexCoords.x, 0.001, 0.999);
reflectionTexCoords.y = clamp(reflectionTexCoords.y, -0.999, -0.001);
vec4 reflectionTex = texture2D(reflection, reflectionTexCoords);
vec4 refractionTex = texture2D(refraction, refractionTexCoords);
vec4 finalColor = mix(refractionTex, reflectionTex, 0.5);
finalColor = mix(finalColor, vec4(0.0, 0.3, 0.2, 1.0), 0.5);
gl_FragColor = finalColor;