diff --git a/grafika_projekt/shaders/bubble.frag b/grafika_projekt/shaders/bubble.frag index 8b94a78..c37f35e 100644 --- a/grafika_projekt/shaders/bubble.frag +++ b/grafika_projekt/shaders/bubble.frag @@ -1,5 +1,5 @@ #version 330 core -out vec4 gl_FragColor; + uniform sampler2D textureSampler; in vec3 fragPos; @@ -9,8 +9,9 @@ uniform vec3 cameraPos; uniform samplerCube skybox; void main() -{ +{ + float ratio = 1.00 / 1.52; vec3 I = normalize(fragPos - cameraPos); - vec3 R = reflect(I, normalize(interpNormal)); - gl_FragColor = vec4(texture(skybox, R).rgb, 1.0); + vec3 R = refract(I, normalize(interpNormal),ratio); + gl_FragColor = vec4(texture(textureSampler, R).rgb, 1.0); } \ No newline at end of file diff --git a/grafika_projekt/shaders/bubble.vert b/grafika_projekt/shaders/bubble.vert index ad5fa24..ee1d9c6 100644 --- a/grafika_projekt/shaders/bubble.vert +++ b/grafika_projekt/shaders/bubble.vert @@ -10,7 +10,7 @@ uniform mat4 modelViewProjectionMatrix; void main() { - gl_Position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0); - interpNormal = (modelMatrix * vec4(vertexNormal, 0.0)).xyz; - fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz; + interpNormal = mat3(transpose(inverse(modelMatrix))) * vertexNormal; + fragPos = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + gl_Position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0); } \ No newline at end of file