#version 430 compatibility in vec3 fragPos; in vec3 interpNormal; uniform vec3 cameraPos; uniform samplerCube bubble; uniform vec3 lightPos; layout (binding = 0) uniform samplerCube tex_map; void main() { float ratio = 1.33 / 1.00; vec3 I = normalize(fragPos - cameraPos); vec3 Refract = refract(I, normalize(interpNormal), ratio); vec3 Reflect = reflect(I, normalize(interpNormal)); vec3 flip = reflect(normalize(-fragPos), normalize(interpNormal)); vec4 flipColor = texture( tex_map, flip ); vec4 refractionColor = texture(tex_map, Refract); vec4 reflectionColor = texture(tex_map, Reflect); //vec4 color = vec4(mix(flipColor,reflectionColor,0).rgb,1.0); vec4 envColor = vec4(mix( flipColor,refractionColor,0).rgb,0.5); vec3 lightDir = normalize(lightPos-fragPos); vec3 V = normalize(cameraPos-fragPos); vec3 normal = normalize(interpNormal); float diffuse = max(0,dot(normal,normalize(lightDir))); vec3 R = reflect(-normalize(lightDir),normal); float ambient = 0.5; float specular = pow(max(0,dot(R,V)),10); gl_FragColor = (envColor*(ambient + (1-ambient)*diffuse)+vec4(1)*specular*0.2); }