change bubble.frag to reflective

This commit is contained in:
Thyme1 2022-01-01 14:05:58 +01:00
parent 33a09475d2
commit 78dbab04f5
4 changed files with 10 additions and 7 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -10,6 +10,7 @@ in vec3 fragPos;
in vec3 interpNormal;
in vec2 interpTexCoord;
void main()
{
vec3 lightDir = normalize(lightPos-fragPos);

View File

@ -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;