diff --git a/cw 9/shaders/shader_9_1.frag b/cw 9/shaders/shader_9_1.frag index 5cbd46e..5a9f249 100644 --- a/cw 9/shaders/shader_9_1.frag +++ b/cw 9/shaders/shader_9_1.frag @@ -133,12 +133,12 @@ void main() //flashlight //vec3 spotlightDir= normalize(spotlightDirTS); - vec3 spotlightDir= normalize(spotlightPos-worldPos); + //vec3 spotlightDir= normalize(spotlightPos-worldPos); - float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); - attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2); - ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); + //float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); + //attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2); + //ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //sun ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); diff --git a/cw 9/shaders/shader_texture.frag b/cw 9/shaders/shader_texture.frag index a6a9503..daa0865 100644 --- a/cw 9/shaders/shader_texture.frag +++ b/cw 9/shaders/shader_texture.frag @@ -135,12 +135,12 @@ void main() //flashlight //vec3 spotlightDir= normalize(spotlightDirTS); - vec3 spotlightDir= normalize(spotlightPos-worldPos); + //vec3 spotlightDir= normalize(spotlightPos-worldPos); - float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); - attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2); - ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); + //float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); + //attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2); + //ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //sun ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index eced130..6907396 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -89,12 +89,9 @@ Core::Shader_Loader shaderLoader; Core::RenderContext shipContext; Core::RenderContext sphereContext; -glm::vec3 sunPos = glm::vec3(-0.028716f, 2.06441f, 3.84067f); -glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106f, 0.003226f); -glm::vec3 sunColor = glm::vec3(0.9f, 0.6f, 0.7f) * 5; -glm::vec3 sunColor1 = glm::vec3(0.9f, 0.6f, 0.7f) * 5; -glm::vec3 sunColor2 = glm::vec3(1.0f, 0.2f, 0.2f) * 5; -glm::vec3 sunColor3 = glm::vec3(1.0f, 0.2f, 0.2f) * 5; +glm::vec3 sunPos = glm::vec3(0.f, 0.f, 0.f); +glm::vec3 sunDir = glm::vec3(0.f, 4.f, 0.f); +glm::vec3 sunColor = glm::vec3(0.9f, 0.6f, 0.7f) * 0.15; glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f); glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f); @@ -108,12 +105,17 @@ float aspectRatio = 1.f; float exposition = 1.f; +glm::vec3 lampColor = glm::vec3(0.9f, 0.6f, 0.7f) * 5; +glm::vec3 lampColor2 = glm::vec3(1.0f, 0.2f, 0.2f) * 5; +glm::vec3 lampColor3 = glm::vec3(1.0f, 0.2f, 0.2f) * 5; + glm::vec3 pointlightPos = glm::vec3(-3.5, 2.8, 0); glm::vec3 pointlightPos2 = glm::vec3(4.5, 2.8, 3); glm::vec3 pointlightPos3 = glm::vec3(4.5, 2.8, -2.99); -glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6) * 20; -glm::vec3 pointlightColor2 = glm::vec3(1, 0.2, 0.2) * 10; -glm::vec3 pointlightColor3 = glm::vec3(1, 0.2, 0.2) * 10; + +glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6) * 30; +glm::vec3 pointlightColor2 = glm::vec3(1, 0.2, 0.2) * 20; +glm::vec3 pointlightColor3 = glm::vec3(1, 0.2, 0.2) * 20; glm::vec3 spotlightPos = glm::vec3(0, 0, 0); @@ -150,6 +152,7 @@ unsigned int skyboxIndices[] = 6, 2, 3 }; +/* std::string facesCubemap[6] = { "./textures/skybox/rt.png", @@ -159,6 +162,18 @@ std::string facesCubemap[6] = "./textures/skybox/ft.png", "./textures/skybox/bk.png" }; +*/ +std::string facesCubemap[6] = +{ + "./textures/skybox/space_lf.png", + "./textures/skybox/space_rt.png", + "./textures/skybox/space_up.png", + "./textures/skybox/space_dn.png", + "./textures/skybox/space_ft.png", + "./textures/skybox/space_bk.png" +}; + + unsigned int cubemapTexture; @@ -387,19 +402,19 @@ void renderScene(GLFWwindow* window) //glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix(); glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)); glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation); - glUniform3f(glGetUniformLocation(programSun, "color"), sunColor1.x / 2, sunColor1.y / 2, sunColor1.z / 2); + glUniform3f(glGetUniformLocation(programSun, "color"), lampColor.x / 2, lampColor.y / 2, lampColor.z / 2); glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition); Core::DrawContext(sphereContext); glm::mat4 transformation2 = viewProjectionMatrix * glm::translate(pointlightPos2) * glm::scale(glm::vec3(0.1)); glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation2); - glUniform3f(glGetUniformLocation(programSun, "color"), sunColor2.x / 2, sunColor2.y / 2, sunColor2.z / 2); + glUniform3f(glGetUniformLocation(programSun, "color"), lampColor2.x / 2, lampColor2.y / 2, lampColor2.z / 2); glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition); Core::DrawContext(sphereContext); glm::mat4 transformation3 = viewProjectionMatrix * glm::translate(pointlightPos3) * glm::scale(glm::vec3(0.1)); glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation3); - glUniform3f(glGetUniformLocation(programSun, "color"), sunColor3.x / 2, sunColor3.y / 2, sunColor3.z / 2); + glUniform3f(glGetUniformLocation(programSun, "color"), lampColor3.x / 2, lampColor3.y / 2, lampColor3.z / 2); glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition); Core::DrawContext(sphereContext); @@ -505,6 +520,9 @@ void renderScene(GLFWwindow* window) drawObjectPBRWithTexture(models::door_next_toContext, glm::mat4(), texture::door_next_toTexture, 0.5f, 0.0f); drawObjectPBRWithTexture(models::door_next_to_doorhandleContext, glm::mat4(), texture::door_next_to_doorhandleTexture, 0.5f, 0.0f); + //objects with textures that contain transparency should be drawn here (last) + drawObjectPBRWithTexture(models::glassWallContext, glm::mat4(), texture::glassWallTexture, 0.8f, 0.0f); + //test depth buffer //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glUseProgram(programTest); @@ -512,9 +530,6 @@ void renderScene(GLFWwindow* window) //glBindTexture(GL_TEXTURE_2D, depthMap); //Core::DrawContext(models::testContext); - //objects with textures that contain transparency should be drawn here (last) - drawObjectPBRWithTexture(models::glassWallContext, glm::mat4(), texture::glassWallTexture, 0.8f, 0.0f); - glUseProgram(0); glfwSwapBuffers(window); } @@ -586,11 +601,11 @@ void init(GLFWwindow* window) glDisable(GL_BLEND); programTex = shaderLoader.CreateProgram("shaders/shader_texture.vert", "shaders/shader_texture.frag"); texture::fishTexture = Core::LoadTexture("textures/fish.png"); - texture::roomTexture = Core::LoadTexture("textures/wall.jpg"); + texture::roomTexture = Core::LoadTexture("textures/roof.jpg"); texture::sofaBaseTexture = Core::LoadTexture("textures/sofa.jpg"); texture::sofaTexture = Core::LoadTexture("textures/sofa.jpg"); - texture::landTexture = Core::LoadTexture("textures/land.jpg"); - texture::floorTexture = Core::LoadTexture("textures/floor3.png"); + texture::landTexture = Core::LoadTexture("textures/grass.jpg"); + texture::floorTexture = Core::LoadTexture("textures/floor.png"); texture::roofTexture = Core::LoadTexture("textures/roof.jpg"); texture::door1Texture = Core::LoadTexture("textures/Door.jpg"); texture::door2Texture = Core::LoadTexture("textures/Door.jpg"); diff --git a/cw 9/textures/floor.png b/cw 9/textures/floor.png new file mode 100644 index 0000000..8ad9d32 Binary files /dev/null and b/cw 9/textures/floor.png differ diff --git a/cw 9/textures/grass.jpg b/cw 9/textures/grass.jpg new file mode 100644 index 0000000..d2ca0cd Binary files /dev/null and b/cw 9/textures/grass.jpg differ diff --git a/cw 9/textures/skybox/alt_bk.jpg b/cw 9/textures/skybox/alt_bk.jpg new file mode 100644 index 0000000..4ea5f2b Binary files /dev/null and b/cw 9/textures/skybox/alt_bk.jpg differ diff --git a/cw 9/textures/skybox/alt_dn.jpg b/cw 9/textures/skybox/alt_dn.jpg new file mode 100644 index 0000000..b876177 Binary files /dev/null and b/cw 9/textures/skybox/alt_dn.jpg differ diff --git a/cw 9/textures/skybox/alt_ft.jpg b/cw 9/textures/skybox/alt_ft.jpg new file mode 100644 index 0000000..40c93f5 Binary files /dev/null and b/cw 9/textures/skybox/alt_ft.jpg differ diff --git a/cw 9/textures/skybox/alt_lf.jpg b/cw 9/textures/skybox/alt_lf.jpg new file mode 100644 index 0000000..074de48 Binary files /dev/null and b/cw 9/textures/skybox/alt_lf.jpg differ diff --git a/cw 9/textures/skybox/alt_rt.jpg b/cw 9/textures/skybox/alt_rt.jpg new file mode 100644 index 0000000..c23e10b Binary files /dev/null and b/cw 9/textures/skybox/alt_rt.jpg differ diff --git a/cw 9/textures/skybox/alt_up.jpg b/cw 9/textures/skybox/alt_up.jpg new file mode 100644 index 0000000..0147247 Binary files /dev/null and b/cw 9/textures/skybox/alt_up.jpg differ diff --git a/cw 9/textures/skybox/space_bk.png b/cw 9/textures/skybox/space_bk.png new file mode 100644 index 0000000..7a67e73 Binary files /dev/null and b/cw 9/textures/skybox/space_bk.png differ diff --git a/cw 9/textures/skybox/space_dn.png b/cw 9/textures/skybox/space_dn.png new file mode 100644 index 0000000..4191f53 Binary files /dev/null and b/cw 9/textures/skybox/space_dn.png differ diff --git a/cw 9/textures/skybox/space_ft.png b/cw 9/textures/skybox/space_ft.png new file mode 100644 index 0000000..5aba731 Binary files /dev/null and b/cw 9/textures/skybox/space_ft.png differ diff --git a/cw 9/textures/skybox/space_lf.png b/cw 9/textures/skybox/space_lf.png new file mode 100644 index 0000000..e7b65cb Binary files /dev/null and b/cw 9/textures/skybox/space_lf.png differ diff --git a/cw 9/textures/skybox/space_rt.png b/cw 9/textures/skybox/space_rt.png new file mode 100644 index 0000000..8366b78 Binary files /dev/null and b/cw 9/textures/skybox/space_rt.png differ diff --git a/cw 9/textures/skybox/space_up.png b/cw 9/textures/skybox/space_up.png new file mode 100644 index 0000000..61626da Binary files /dev/null and b/cw 9/textures/skybox/space_up.png differ