From 78dbab04f58c243dbd369aff874af47aa3136ec4 Mon Sep 17 00:00:00 2001 From: Thyme1 Date: Sat, 1 Jan 2022 14:05:58 +0100 Subject: [PATCH] change bubble.frag to reflective --- grafika_projekt/shaders/bubble.frag | 10 +++++----- grafika_projekt/shaders/bubble.vert | 2 ++ grafika_projekt/shaders/shader_tex.frag | 1 + grafika_projekt/src/main.cpp | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/grafika_projekt/shaders/bubble.frag b/grafika_projekt/shaders/bubble.frag index c37f35e..6419677 100644 --- a/grafika_projekt/shaders/bubble.frag +++ b/grafika_projekt/shaders/bubble.frag @@ -1,17 +1,17 @@ #version 330 core -uniform sampler2D textureSampler; in vec3 fragPos; in vec3 interpNormal; - +in vec3 TexCoords; uniform vec3 cameraPos; uniform samplerCube skybox; void main() { - float ratio = 1.00 / 1.52; + float ratio = 1.01/1.0; vec3 I = normalize(fragPos - cameraPos); - vec3 R = refract(I, normalize(interpNormal),ratio); - gl_FragColor = vec4(texture(textureSampler, R).rgb, 1.0); + // vec3 R = refract(I, normalize(interpNormal),ratio); + vec3 R = reflect(I, normalize(interpNormal)); + gl_FragColor = vec4(texture(skybox, 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 ee1d9c6..2151edd 100644 --- a/grafika_projekt/shaders/bubble.vert +++ b/grafika_projekt/shaders/bubble.vert @@ -4,6 +4,7 @@ layout(location = 1) in vec3 vertexNormal; out vec3 interpNormal; out vec3 fragPos; +out vec3 TexCoords; uniform mat4 modelMatrix; uniform mat4 modelViewProjectionMatrix; @@ -13,4 +14,5 @@ void main() interpNormal = mat3(transpose(inverse(modelMatrix))) * vertexNormal; fragPos = vec3(modelMatrix * vec4(vertexPosition, 1.0)); gl_Position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0); + TexCoords = fragPos; } \ No newline at end of file diff --git a/grafika_projekt/shaders/shader_tex.frag b/grafika_projekt/shaders/shader_tex.frag index 5ec1fe9..c5b3944 100644 --- a/grafika_projekt/shaders/shader_tex.frag +++ b/grafika_projekt/shaders/shader_tex.frag @@ -10,6 +10,7 @@ in vec3 fragPos; in vec3 interpNormal; in vec2 interpTexCoord; + void main() { vec3 lightDir = normalize(lightPos-fragPos); diff --git a/grafika_projekt/src/main.cpp b/grafika_projekt/src/main.cpp index ba44f14..76087ee 100644 --- a/grafika_projekt/src/main.cpp +++ b/grafika_projekt/src/main.cpp @@ -379,7 +379,7 @@ void renderScene() glm::mat4 bubbleInitialTransformation = glm::translate(glm::vec3(0, -0.5, -0.4)) * glm::rotate(glm::radians(180.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.5f)); - drawObjectTexture(bubbleContext, bubbleInitialTransformation, textureBubble, cubeProgram); + //drawObjectTexture(bubbleContext, bubbleInitialTransformation, textureBubble, cubeProgram); glm::vec3 change1 = glm::vec3(0, 3, 0); @@ -396,7 +396,7 @@ void renderScene() drawObjectTexture(fishContext, animationMatrix(time + 15, change2, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture); drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture); drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture); - //drawObjectTexture(bubbleContext, animationMatrix(time + 15, change5, bubbleKeyPoints, glm::vec3(0.01f), 0.2f), GL_TEXTURE_CUBE_MAP, skyboxProgram); + drawObjectTexture(bubbleContext, animationMatrix(time + 15, change5, bubbleKeyPoints, glm::vec3(0.1f), 0.2f), cubemapTexture, cubeProgram); //drawObjectTexture(bubbleContext, animationMatrix(time + 15, change6, bubbleKeyPoints, glm::vec3(0.01f), 0.2f), GL_TEXTURE_CUBE_MAP, skyboxProgram); //drawObjectTexture(bubbleContext, animationMatrix(time + 15, change7, bubbleKeyPoints, glm::vec3(0.01f), 0.2f), GL_TEXTURE_CUBE_MAP, skyboxProgram); time -= 6;