GRK-Projekt/grafika_projekt/shaders/bubble.frag
2022-01-02 00:03:53 +01:00

53 lines
1.3 KiB
GLSL

#version 330 core
in vec3 v_refraction;
in vec3 v_reflection;
in float v_fresnel;
in vec3 fragPos;
in vec3 interpNormal;
in vec3 incident;
in float deep;
uniform samplerCube skybox;
uniform vec3 lightPos;
uniform vec3 cameraPos;
uniform vec3 lightColor;
uniform vec3 objectColor;
const float etaR = 1.14;
const float etaG = 1.12;
const float etaB = 1.10;
const float F = ((1.0 - etaG) * (1.0 - etaG)) / ((1.0 + etaG) * (1.0 + etaG));
void main()
{
vec3 n = normalize(interpNormal);
vec3 l = normalize(lightPos-fragPos);
vec3 e = normalize(cameraPos-fragPos);
vec3 h = (e+l) / length(e+l);
float ratio = 1.01/1.0;
//
vec3 i = incident;
//float ratio = F + (1.0 - F) * pow(1.0 - dot(-i, n), 2);
vec3 refractR = vec3(vec4(refract(i, n, etaR), 1.0));
vec3 refractG = vec3(vec4(refract(i, n, etaG), 1.0));
vec3 refractB = vec3(vec4(refract(i, n, etaB), 1.0));
vec3 reflectDir = vec3(vec4(reflect(i, n), 1.0));
vec3 I = normalize(fragPos - cameraPos);
// vec3 R = refract(I, normalize(interpNormal),ratio);
vec3 R = reflect(I, normalize(interpNormal));
vec4 refractionColor = texture( skybox, normalize( v_refraction ) );
vec4 reflectionColor = texture( skybox, normalize( v_reflection ) );
gl_FragColor = vec4(mix( refractionColor, reflectionColor, v_fresnel ).rgba);
}