2022-02-11 21:24:15 +00:00
|
|
|
#version 460 core
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
2022-10-16 18:27:25 +00:00
|
|
|
in vec3 Normal;
|
|
|
|
in vec3 Position;
|
2022-02-13 13:38:39 +00:00
|
|
|
|
2022-10-16 18:27:25 +00:00
|
|
|
uniform vec3 cameraPos;
|
|
|
|
uniform samplerCube skybox;
|
2022-10-16 18:14:06 +00:00
|
|
|
|
|
|
|
in vec2 TexCoords;
|
2022-02-21 23:32:22 +00:00
|
|
|
uniform sampler2D texture_diffuse1;
|
2022-02-16 19:32:55 +00:00
|
|
|
|
2022-10-16 18:44:48 +00:00
|
|
|
const float air_ri = 1.00;
|
|
|
|
const float water_ri = 1.33;
|
|
|
|
const float Ice_ri = 1.309;
|
|
|
|
const float glass_ri = 1.52;
|
|
|
|
const float diamond_ri = 2.42;
|
|
|
|
|
2022-02-16 20:06:40 +00:00
|
|
|
void main()
|
|
|
|
{
|
2022-10-16 18:44:48 +00:00
|
|
|
// Regular shading
|
2022-10-17 09:56:27 +00:00
|
|
|
vec4 albeno = texture( texture_diffuse1, TexCoords) ;
|
2022-10-16 18:44:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Reflective shading
|
2022-10-16 18:27:25 +00:00
|
|
|
vec3 I = normalize(Position - cameraPos);
|
|
|
|
vec3 R = reflect(I, normalize(Normal));
|
|
|
|
|
2022-10-17 09:56:27 +00:00
|
|
|
vec4 reflections = vec4(texture(skybox,R).rgb, 1.0);
|
2022-10-16 18:44:48 +00:00
|
|
|
|
|
|
|
// Refractive shading
|
2023-05-20 09:17:27 +00:00
|
|
|
float ratio = air_ri/Ice_ri;
|
2022-10-17 09:56:27 +00:00
|
|
|
vec3 I2 = normalize(Position-cameraPos);
|
|
|
|
vec3 R2 = refract(I2, normalize(Normal), ratio);
|
|
|
|
vec4 refractions = vec4(texture(skybox, R2).rgb, 1.0);
|
2022-10-16 18:44:48 +00:00
|
|
|
|
2023-05-20 09:17:27 +00:00
|
|
|
FragColor = vec4(albeno.rgb + (refractions.rgb * 1.0) + (reflections.rgb * 0.0), 1.0);
|
2022-02-11 21:24:15 +00:00
|
|
|
}
|