#version 330 core

#define AIR_IOR 1.0
#define GLASS_IOR 1.52

in VS_OUT {
  vec3 vert_normal;
  vec3 frag_position;
  vec2 uv_coords;
} fs_in;

uniform samplerCube cubemap;

layout (std140) uniform Common {
  mat4 projection;
  mat4 view;
  vec3 camera_position;
};

out vec4 color;

void main() {
  vec3 view_direction    = normalize(fs_in.frag_position - camera_position);
  vec3 refract_direction = refract(view_direction, normalize(fs_in.vert_normal), AIR_IOR / GLASS_IOR);

  color = vec4(texture(cubemap, refract_direction).rgb, 1.0);
}
