uniform sampler2D noise;
uniform sampler2D envmap;

varying vec3 vViewVec;
varying vec2 texCoord;

void main(void) {

   float udistort = (texture2D(noise, texCoord).r - texture2D(noise, vec2(texCoord.x + 0.01, texCoord.y)).r);
   float vdistort = (texture2D(noise, texCoord).r - texture2D(noise, vec2(texCoord.x, texCoord.y + 0.01)).r);

   vec3 col = vec3(texture2D(envmap, vec2(texCoord.x + udistort, texCoord.y + vdistort)));
   gl_FragColor = vec4(col, length(vViewVec));   
//   float vl = length(vViewVec);
//   gl_FragColor = vec4(vl, vl, vl, 1.0);   
   
//   gl_FragColor = texture2D(envmap, vec2(texCoord.x + udistort, texCoord.y + vdistort));
//   gl_FragColor = texture2D(envmap, vec2(texCoord.x, texCoord.y));
   
}
