2022-01-02 01:26:44 +01:00
|
|
|
#version 430 compatibility
|
2021-12-30 12:14:47 +01:00
|
|
|
|
2022-01-02 00:03:53 +01:00
|
|
|
|
2022-01-02 01:26:44 +01:00
|
|
|
in vec3 fragPos;
|
|
|
|
in vec3 interpNormal;
|
2022-01-10 21:14:14 +01:00
|
|
|
|
2022-01-02 00:03:53 +01:00
|
|
|
uniform vec3 cameraPos;
|
2022-01-02 02:22:53 +01:00
|
|
|
uniform samplerCube bubble;
|
2022-01-12 13:28:22 +01:00
|
|
|
uniform vec3 lightPos;
|
2022-01-10 21:14:14 +01:00
|
|
|
|
2022-01-02 01:26:44 +01:00
|
|
|
layout (binding = 0) uniform samplerCube tex_map;
|
2022-01-10 21:14:14 +01:00
|
|
|
|
2021-12-30 12:14:47 +01:00
|
|
|
void main()
|
2022-01-01 12:35:51 +01:00
|
|
|
{
|
2022-01-02 02:22:53 +01:00
|
|
|
float ratio = 1.33 / 1.00;
|
|
|
|
vec3 I = normalize(fragPos - cameraPos);
|
2022-01-02 17:29:41 +01:00
|
|
|
vec3 Refract = refract(I, normalize(interpNormal), ratio);
|
2022-01-10 21:14:14 +01:00
|
|
|
vec3 Reflect = reflect(I, normalize(interpNormal));
|
2022-01-02 17:29:41 +01:00
|
|
|
vec3 flip = reflect(normalize(-fragPos), normalize(interpNormal));
|
|
|
|
vec4 flipColor = texture( tex_map, flip );
|
2022-01-10 21:14:14 +01:00
|
|
|
vec4 refractionColor = texture(tex_map, Refract);
|
|
|
|
vec4 reflectionColor = texture(tex_map, Reflect);
|
2022-01-02 17:29:41 +01:00
|
|
|
//vec4 color = vec4(mix(flipColor,reflectionColor,0).rgb,1.0);
|
2022-01-12 13:28:22 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
2021-12-30 12:14:47 +01:00
|
|
|
}
|