diff --git a/Release/grk-cw9.exe b/Release/grk-cw9.exe index fe49049..bab5869 100644 Binary files a/Release/grk-cw9.exe and b/Release/grk-cw9.exe differ diff --git a/Release/grk-cw9.pdb b/Release/grk-cw9.pdb index 0445ae9..79b2954 100644 Binary files a/Release/grk-cw9.pdb and b/Release/grk-cw9.pdb differ diff --git a/cw 9/Release/grk-cw9.iobj b/cw 9/Release/grk-cw9.iobj index e3b2077..094e15c 100644 Binary files a/cw 9/Release/grk-cw9.iobj and b/cw 9/Release/grk-cw9.iobj differ diff --git a/cw 9/Release/grk-cw9.ipdb b/cw 9/Release/grk-cw9.ipdb index f3f8f00..01870a8 100644 Binary files a/cw 9/Release/grk-cw9.ipdb and b/cw 9/Release/grk-cw9.ipdb differ diff --git a/cw 9/Release/grk-cw9.log b/cw 9/Release/grk-cw9.log index 06a4068..00d5dab 100644 --- a/cw 9/Release/grk-cw9.log +++ b/cw 9/Release/grk-cw9.log @@ -9,77 +9,88 @@ C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warni C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(101,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(111,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(115,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(338,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(355,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(380,38): warning C4305: "=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(409,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(614,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(622,73): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(622,66): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(637,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(655,98): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(337,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(375,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(400,38): warning C4305: "=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(429,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(642,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(650,73): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(650,66): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(665,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(683,98): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(658,68): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(686,68): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(702,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(716,99): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(731,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(745,99): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(719,69): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(748,69): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(822,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(823,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(824,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(827,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(828,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(884,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(885,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(886,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(889,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(890,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(996,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1009,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(793,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(807,99): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1018,87): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(810,69): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1018,223): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1047,73): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1051,81): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1052,93): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1053,83): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1054,83): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1149,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(934,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(935,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(936,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(939,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(940,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(996,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(997,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(998,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1001,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1002,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1108,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1122,108): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1470,66): warning C4244: "=": konwersja z "double" do "T", możliwa utrata danych +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1131,87): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1487,21): warning C4305: "-=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1489,21): warning C4305: "+=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1131,223): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1160,73): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1164,81): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1165,93): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1166,83): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1167,83): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1263,108): warning C4305: "argument": obcięcie z "double" do "T" + with + [ + T=float + ] +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1592,66): warning C4244: "=": konwersja z "double" do "T", możliwa utrata danych + with + [ + T=float + ] +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1609,21): warning C4305: "-=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1611,21): warning C4305: "+=": obcięcie z "double" do "float" Trwa generowanie kodu - 1 of 717 functions ( 0.1%) were compiled, the rest were copied from previous compilation. + 1 of 723 functions ( 0.1%) were compiled, the rest were copied from previous compilation. 0 functions were new in current compilation - 7 functions had inline decision re-evaluated but remain unchanged + 9 functions had inline decision re-evaluated but remain unchanged Zakończono generowanie kodu grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\g\GRK_Project\Release\grk-cw9.exe diff --git a/cw 9/Release/grk-cw9.tlog/CL.read.1.tlog b/cw 9/Release/grk-cw9.tlog/CL.read.1.tlog index 0f17c32..6e86bb2 100644 Binary files a/cw 9/Release/grk-cw9.tlog/CL.read.1.tlog and b/cw 9/Release/grk-cw9.tlog/CL.read.1.tlog differ diff --git a/cw 9/Release/grk-cw9.tlog/CL.write.1.tlog b/cw 9/Release/grk-cw9.tlog/CL.write.1.tlog index 566658b..d6e9d79 100644 Binary files a/cw 9/Release/grk-cw9.tlog/CL.write.1.tlog and b/cw 9/Release/grk-cw9.tlog/CL.write.1.tlog differ diff --git a/cw 9/Release/grk-cw9.tlog/link.read.1.tlog b/cw 9/Release/grk-cw9.tlog/link.read.1.tlog index 8ef3e4a..020e969 100644 Binary files a/cw 9/Release/grk-cw9.tlog/link.read.1.tlog and b/cw 9/Release/grk-cw9.tlog/link.read.1.tlog differ diff --git a/cw 9/Release/grk-cw9.tlog/link.write.1.tlog b/cw 9/Release/grk-cw9.tlog/link.write.1.tlog index 451d3e1..54cb32b 100644 Binary files a/cw 9/Release/grk-cw9.tlog/link.write.1.tlog and b/cw 9/Release/grk-cw9.tlog/link.write.1.tlog differ diff --git a/cw 9/Release/main.obj b/cw 9/Release/main.obj index 862d4bb..8a08435 100644 Binary files a/cw 9/Release/main.obj and b/cw 9/Release/main.obj differ diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index dec7c13..db87a6f 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -92,6 +92,7 @@ namespace models { Core::RenderContext painting2Context; Core::RenderContext mug2Context; Core::RenderContext bookContext; + Core::RenderContext lampContext; } std::vector faces = { @@ -263,12 +264,20 @@ namespace texture { GLuint spray_roughness; GLuint spray_ao; GLuint spray_normal; + + GLuint lamp_albedo; + GLuint lamp_metallic; + GLuint lamp_ao; + GLuint lamp_roughness; + GLuint lamp_normal; } GLuint depthMapFBO; GLuint depthMap; GLuint depthMapFBO2; GLuint depthMap2; +GLuint depthMapFBO3; +GLuint depthMap3; int speed = 300; @@ -325,17 +334,28 @@ GLuint VAO, VBO; float aspectRatio = 1.f; float exposition = 1.f; +float spotlightPhi = 3.14 / 4; + +glm::vec3 spotlightPos = glm::vec3(1.5, 1.15, -1.1); +glm::vec3 spotlightConeDir = glm::vec3(0, -1, 0); +glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0)); glm::mat4 lightVP2 = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos2, sunPos2 - sunDir2, glm::vec3(0, 1, 0)); +glm::mat4 lightVP3 = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(spotlightPos, spotlightPos - spotlightConeDir, glm::vec3(0, 1, 0)); +//glm::mat4 lightVP3 = glm::ortho(-10.0f,10.0f,-10.0f,10.0f,0.1f,10.f) * glm::lookAt(spotlightPos, -spotlightConeDir,glm::vec3(0.0,1.0,0.0)); +glm::mat4 ort = glm::ortho(-3.0f, 3.0f, -3.0f, 3.0f, 0.1f, 3.0f); +glm::mat4 lightView = glm::lookAt(spotlightPos, spotlightPos+spotlightConeDir, glm::vec3(0.0, 1.0, 0.0)); +//glm::mat4 lightVP3 = glm::perspective(glm::radians(180.0f), 1.0f, 0.05f, 25.0f) * glm::lookAt(spotlightPos, spotlightPos - spotlightConeDir, glm::vec3(0, 1, 0)); +//glm::mat4 lightVP3 = ort * lightView; glm::vec3 pointlightPos = glm::vec3(0, 2, 0); glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); -glm::vec3 spotlightPos = glm::vec3(0, 0, 0); -glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0); -glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; -float spotlightPhi = 3.14 / 4; +//glm::vec3 spotlightPos = glm::vec3(0, 0, 0); +//glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0); +//glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; + glm::vec3 lightPos = glm::vec3(-8, 4, 2); @@ -456,6 +476,8 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec Core::SetActiveTexture(depthMap, "depthMap", program, 0); glUniformMatrix4fv(glGetUniformLocation(program, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); Core::SetActiveTexture(depthMap2, "depthMap2", program, 1); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP3"), 1, GL_FALSE, (float*)&lightVP3); + Core::SetActiveTexture(depthMap3, "depthMap3", program, 2); Core::DrawContext(context); } @@ -496,6 +518,8 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro Core::SetActiveTexture(depthMap, "depthMap", programTex, 1); glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); Core::SetActiveTexture(depthMap2, "depthMap2", programTex, 2); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP3"), 1, GL_FALSE, (float*)&lightVP3); + Core::SetActiveTexture(depthMap3, "depthMap3", program, 3); Core::DrawContext(context); } @@ -540,6 +564,8 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0); glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR, 6); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP3"), 1, GL_FALSE, (float*)&lightVP3); + Core::SetActiveTexture(depthMap3, "depthMap3", program, 7); Core::DrawContext(context); } @@ -582,6 +608,8 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G Core::SetActiveTexture(depthMap, "depthMap", programTexPBR_ARM, 0); glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR_ARM, 4); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP3"), 1, GL_FALSE, (float*)&lightVP3); + Core::SetActiveTexture(depthMap3, "depthMap3", program, 5); Core::DrawContext(context); } @@ -693,6 +721,7 @@ void renderShadowapSun(float angle) { drawObjectDepth(models::painting2Context, lightVP, glm::mat4()); drawObjectDepth(models::mug2Context, lightVP, glm::mat4()); drawObjectDepth(models::bookContext, lightVP, glm::mat4()); + drawObjectDepth(models::lampContext, lightVP, glm::mat4()); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, WIDTH, HEIGHT); @@ -754,6 +783,69 @@ void renderShadowapSun2() { drawObjectDepth(models::painting2Context, lightVP2, glm::mat4()); drawObjectDepth(models::mug2Context, lightVP2, glm::mat4()); drawObjectDepth(models::bookContext, lightVP2, glm::mat4()); + drawObjectDepth(models::lampContext, lightVP2, glm::mat4()); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glViewport(0, 0, WIDTH, HEIGHT); +} + +void renderShadowapLamp() { + float time = glfwGetTime(); + glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT); + //uzupelnij o renderowanie glebokosci do tekstury + glUseProgram(programDepth); + + //ustawianie przestrzeni rysowania + glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT); + //bindowanie FBO + glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO3); + //czyszczenie mapy głębokości + glClear(GL_DEPTH_BUFFER_BIT); + //ustawianie programu + glUseProgram(programDepth); + + drawObjectDepth(sphereContext, lightVP3, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f))); + + drawObjectDepth(sphereContext, + lightVP3, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f))); + + drawObjectDepth(models::bedContext, lightVP3, glm::mat4()); + drawObjectDepth(models::mattressContext, lightVP3, glm::mat4()); + drawObjectDepth(models::bed_pillowContext, lightVP3, glm::mat4()); + drawObjectDepth(models::floorContext, lightVP3, glm::mat4()); + drawObjectDepth(models::desk_topContext, lightVP3, glm::mat4()); + drawObjectDepth(models::desk_bottomContext, lightVP3, glm::mat4()); + drawObjectDepth(models::framesContext, lightVP3, glm::mat4()); + drawObjectDepth(models::wallContext, lightVP3, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP3, glm::mat4()); + drawObjectDepth(models::couchContext, lightVP3, glm::mat4()); + drawObjectDepth(models::laptopContext, lightVP3, glm::mat4()); + drawObjectDepth(models::doorContext, lightVP3, glm::mat4()); + drawObjectDepth(models::chairContext, lightVP3, glm::mat4()); + drawObjectDepth(models::roofContext, lightVP3, glm::mat4()); + drawObjectDepth(models::blanketContext, lightVP3, glm::mat4()); + drawObjectDepth(models::drawerContext, lightVP3, glm::mat4()); + drawObjectDepth(models::clockContext, lightVP3, glm::mat4()); + drawObjectDepth(models::plantContext, lightVP3, glm::mat4()); + drawObjectDepth(models::c_tableContext, lightVP3, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP3, glm::mat4()); + drawObjectDepth(models::mugContext, lightVP3, glm::mat4()); + drawObjectDepth(models::carContext, lightVP3, glm::mat4()); + drawObjectDepth(models::books1Context, lightVP3, glm::mat4()); + drawObjectDepth(models::books2Context, lightVP3, glm::mat4()); + drawObjectDepth(models::cactusContext, lightVP3, glm::mat4()); + drawObjectDepth(models::fanContext, lightVP3, glm::mat4()); + drawObjectDepth(models::fanTopContext, lightVP3, glm::mat4()); + drawObjectDepth(models::tableContext, lightVP3, glm::mat4()); + drawObjectDepth(models::handleContext, lightVP3, glm::mat4()); + drawObjectDepth(models::pillow1Context, lightVP3, glm::mat4()); + drawObjectDepth(models::pillow2Context, lightVP3, glm::mat4()); + drawObjectDepth(models::pillow3Context, lightVP3, glm::mat4()); + drawObjectDepth(models::painting1Context, lightVP3, glm::mat4()); + drawObjectDepth(models::painting2Context, lightVP3, glm::mat4()); + drawObjectDepth(models::mug2Context, lightVP3, glm::mat4()); + drawObjectDepth(models::bookContext, lightVP3, glm::mat4()); + drawObjectDepth(models::lampContext, lightVP3, glm::mat4()); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, WIDTH, HEIGHT); @@ -799,6 +891,26 @@ void initDepthMap2() glBindFramebuffer(GL_FRAMEBUFFER, 0); } +void initDepthMap3() +{ + glGenFramebuffers(1, &depthMapFBO3); + + glGenTextures(1, &depthMap3); + glBindTexture(GL_TEXTURE_2D, depthMap3); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, + SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO3); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap3, 0); + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + void drawObjectColorWater(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float time, GLuint textureID) { glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * glm::mat4(glm::mat3(createCameraMatrix())); @@ -1002,6 +1114,7 @@ void renderScene(GLFWwindow* window) glm::mat4 rotate = p2 * glm::rotate(glm::mat4(), glm::radians(angle * speed), glm::vec3(1, 0, 0)) * p1; renderShadowapSun(angle); renderShadowapSun2(); + renderShadowapLamp(); //space lamp glUseProgram(programSun); @@ -1036,8 +1149,8 @@ void renderScene(GLFWwindow* window) // ); - spotlightPos = spaceshipPos + 0.2 * spaceshipDir; - spotlightConeDir = spaceshipDir; + //spotlightPos = spaceshipPos + 0.2 * spaceshipDir; + //spotlightConeDir = spaceshipDir; glUseProgram(programTex); //drawObjectTex(models::marbleBustContext, glm::translate(glm::mat4(), glm::vec3(0, 0, -0.2)), 0.2, 0, texture::rust); @@ -1080,6 +1193,7 @@ void renderScene(GLFWwindow* window) glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.03f)), texture::spray_roughness, texture::spray_metallic, texture::spray_albedo, texture::spray_normal, texture::spray_ao ); + drawObjectTexPBR(models::lampContext, glm::mat4(), texture::lamp_roughness, texture::lamp_metallic, texture::lamp_albedo, texture::lamp_normal, texture::lamp_ao); glUseProgram(programTexPBR_ARM); //drawObjectTexPBR_ARM(models::chairContext, glm::mat4(), texture::rock_albedo, texture::rock_normal, texture::rock_arm); @@ -1105,7 +1219,7 @@ void renderScene(GLFWwindow* window) /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programTest); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, depthMap); + glBindTexture(GL_TEXTURE_2D, depthMap3); Core::DrawContext(models::testContext);*/ bubbleManager(); @@ -1150,6 +1264,7 @@ void init(GLFWwindow* window) glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); initDepthMap(); initDepthMap2(); + initDepthMap3(); PlaySound(TEXT("sound/ocean.wav"), NULL, SND_ASYNC|SND_LOOP); glEnable(GL_DEPTH_TEST); program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag"); @@ -1318,6 +1433,12 @@ void init(GLFWwindow* window) texture::spray_ao = Core::LoadTexture("textures/spray/ao.png"); texture::spray_normal = Core::LoadTexture("textures/spray/normal.png"); + texture::lamp_albedo = Core::LoadTexture("textures/lamp/albedo.png"); + texture::lamp_metallic = Core::LoadTexture("textures/lamp/metallic.png"); + texture::lamp_roughness = Core::LoadTexture("textures/lamp/roughness.png"); + texture::lamp_ao = Core::LoadTexture("textures/lamp/ao.png"); + texture::lamp_normal = Core::LoadTexture("textures/lamp/normal.png"); + texture::metal = Core::LoadTexture("textures/metal.png"); loadModelToContext("models/bubble.obj", bubbleContext, false); @@ -1349,7 +1470,7 @@ void init(GLFWwindow* window) loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false); loadModelToContext("./models/paplan.obj", models::blanketContext, false); - loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, true); + loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, false); loadModelToContext("./models/PC_desk_bake_004.obj", models::desk_bottomContext, false); loadModelToContext("./models/Cube_002.obj", models::paper_stack2Context, false); loadModelToContext("./models/Cube_009.obj", models::paper_stack3Context, false); @@ -1385,6 +1506,7 @@ void init(GLFWwindow* window) loadModelToContext("./models/painting2.obj", models::painting2Context, false); loadModelToContext("./models/mug2.obj", models::mug2Context, false); loadModelToContext("./models/book.obj", models::bookContext, false); + loadModelToContext("./models/lamp.obj", models::lampContext, false); collisionSystem.calculateSceneBounding(); diff --git a/cw 9/textures/lamp/albedo.png b/cw 9/textures/lamp/albedo.png new file mode 100644 index 0000000..28faa05 Binary files /dev/null and b/cw 9/textures/lamp/albedo.png differ diff --git a/cw 9/textures/lamp/ao.png b/cw 9/textures/lamp/ao.png new file mode 100644 index 0000000..90d81dc Binary files /dev/null and b/cw 9/textures/lamp/ao.png differ diff --git a/cw 9/textures/lamp/metallic.png b/cw 9/textures/lamp/metallic.png new file mode 100644 index 0000000..8f19996 Binary files /dev/null and b/cw 9/textures/lamp/metallic.png differ diff --git a/cw 9/textures/lamp/normal.png b/cw 9/textures/lamp/normal.png new file mode 100644 index 0000000..51eda29 Binary files /dev/null and b/cw 9/textures/lamp/normal.png differ diff --git a/cw 9/textures/lamp/roughness.png b/cw 9/textures/lamp/roughness.png new file mode 100644 index 0000000..3cd7292 Binary files /dev/null and b/cw 9/textures/lamp/roughness.png differ