diff --git a/shader.fs b/shader.fs index 31515c0..ae52273 100644 --- a/shader.fs +++ b/shader.fs @@ -19,24 +19,20 @@ const float diamond_ri = 2.42; void main() { // Regular shading - FragColor = texture( texture_diffuse1, TexCoords) ; + vec4 albeno = texture( texture_diffuse1, TexCoords) ; // Reflective shading - /* vec3 I = normalize(Position - cameraPos); vec3 R = reflect(I, normalize(Normal)); - FragColor = vec4(texture(skybox,R).rgb, 1.0); - */ - + vec4 reflections = vec4(texture(skybox,R).rgb, 1.0); // Refractive shading - /* - float ratio = air_ri/water_ri; - vec3 I = normalize(Position-cameraPos); - vec3 R = refract(I, normalize(Normal), ratio); - FragColor = vec4(texture(skybox, R).rgb, 1.0); - */ + float ratio = air_ri/diamond_ri; + vec3 I2 = normalize(Position-cameraPos); + vec3 R2 = refract(I2, normalize(Normal), ratio); + vec4 refractions = vec4(texture(skybox, R2).rgb, 1.0); + FragColor = vec4(albeno.rgb + (refractions.rgb * 0.5) + (reflections.rgb * 0.8), 1.0); } \ No newline at end of file diff --git a/src/Cubemap.cpp b/src/Cubemap.cpp index 5c8c34d..53aea6a 100644 --- a/src/Cubemap.cpp +++ b/src/Cubemap.cpp @@ -10,7 +10,9 @@ Cubemap::~Cubemap(){ } void Cubemap::Bind(){ + glBindTexture(GL_TEXTURE_CUBE_MAP, id); + }; void Cubemap::Unbind(){ diff --git a/src/main.cpp b/src/main.cpp index acd75ed..bdcca61 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -188,13 +188,18 @@ void Skybox_pass (GLuint& SkyboxVAO, Shader& skyboxShader, Cubemap& skycubemap) void drawScene_pass(Shader& shader, Model& Object, Cubemap& skybox) { shader.use(); - shader.setVec3("cameraPos", camera.Position); + + glActiveTexture(GL_TEXTURE11); skybox.Bind(); + glActiveTexture(GL_TEXTURE0); + + shader.setMat4("model", model); shader.setMat4("view", view); shader.setMat4("projection", projection); - + shader.setInt("skybox",11); + Object.Draw(shader); }