uniform samplerCube Env; uniform sampler2D NormalMap; uniform vec3 CamPos; uniform float WaterTimer; varying vec3 camVec; void main() { vec2 texCoord = gl_TexCoord[0].st; mat3 rot; rot[0] = vec3(0.0,0.0,1.0); rot[1] = vec3(1.0,0.0,0.0); rot[2] = vec3(0.0,1.0,0.0); float sinx = 0.025*sin(WaterTimer+texCoord.x*5); vec3 NVec1 = texture2D(NormalMap, vec2(-WaterTimer*0.04 + texCoord.x + sinx, -WaterTimer*0.04 + texCoord.y - sinx)).rgb; vec3 NVec2 = texture2D(NormalMap, vec2( WaterTimer*0.04 + texCoord.y - sinx, -WaterTimer*0.04 + (1.0-texCoord.x) + sinx)).rgb; NVec1 = (NVec1 -0.5) * 2.0; NVec2 = (NVec2 -0.5) * 2.0; vec3 NVec = NVec1 + NVec2; vec3 NVecReflect = normalize(rot * (NVec1 + NVec2) + vec3(0,8,0)); vec3 NVecRefract = normalize(rot * (NVec1 + NVec2)); vec3 dir1 = reflect((camVec),NVecReflect); //vec3 dir2 = refract((camVec),NVecRefract,0.9); vec3 dir2 = reflect((camVec),NVecReflect); dir2.y = - dir2.y; vec4 reflectColor = textureCube(Env, dir1); vec4 refractColor = textureCube(Env, dir2); vec4 texColor = reflectColor*0.2 + refractColor*0.8; gl_FragColor = vec4(texColor.xyz, 1.0f); }