   GLSL water reflection/refraction problem
  Hi!I'm making a water system, using a triangulated 150x150 vertices plane and a dynamic cube map for reflection and refraction. The problem is the reflection and refraction part, which is processed with GLSL. I use the shader examples for this from The Orange Book and the result is kinda right, but still very wrong (got the same problem when I wrote my own shader code at first). The surface seem to behave a bit like a magnifying glass, this becomes more apparent when zooming in and out.I think this could have something to do with the cube map being created from the center of the scene and that vertices positioned away from the center use the same cube map, which result in incorrect reflection- and refraction vectors. If zooming out, the incident vectors to the surface will become almost parallel and make the texture look-ups from a too narrow area of the cube map. The only vertice having the correct reflection/refraction is the one in the center.Maybe this problem could be solved if the incident vectors were magnified by the vertex offset position. I've been trying to do this, but haven't figured out the right way (beginner to GLSL). Or maybe the solution lies elsewhere. Anyway, I would be very thankful if you could help me.I uploaded a video to show the problem:(Same videos, different coders. They seem to work best for me with Windows Media Player, not at all with VLC)Water video 26MbWater video 28MbVertx shader:varying vec3  Reflect;varying vec3  Refract;varying float Ratio;const float Eta = 0.33;    // Ratio of indices of refractionconst float FresnelPower = 5.0;const float F  = ((1.0-Eta) * (1.0-Eta)) / ((1.0+Eta) * (1.0+Eta));void main(){    vec4 ecPosition  = gl_ModelViewMatrix * gl_Vertex;    vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;    vec3 i = normalize(ecPosition3);    vec3 n = normalize(gl_NormalMatrix * gl_Normal);    Ratio   = F [PLUS] (1.0 - F) * pow((1.0 - dot(-i, n)), FresnelPower);   Refract = refract(i, n, Eta);    Refract = vec3(gl_TextureMatrix[0] * vec4(Refract, 1.0));    Reflect = reflect(i, n);    Reflect = vec3(gl_TextureMatrix[0] * vec4(Reflect, 1.0));    gl_Position = ftransform();}OBS, the editor didn't seem to be able to process plus-signs, hence the [PLUS].Fragment shader:varying vec3  Reflect;varying vec3  Refract;varying float Ratio;uniform samplerCube cubeMap;void main(){    vec3 refractColor = vec3(textureCube(cubeMap, Refract));    vec3 reflectColor = vec3(textureCube(cubeMap, Reflect));    vec3 color   = mix(refractColor, reflectColor, Ratio);    gl_FragColor = 0.7 * vec4(color, 1.0) [PLUS] 0.3 * vec4( 0.0, 0.0, 1.0, 1.0 ); // adding a blueish tone}Screenshots, changing the distance from the surface:The source code
  Cant you just use normals for reflection/refraction coordinates?   