diff --git a/Release/grk-cw9.exe b/Release/grk-cw9.exe index 3c18762..2f89c2e 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 d545988..cd714de 100644 Binary files a/Release/grk-cw9.pdb and b/Release/grk-cw9.pdb differ diff --git a/cw 9/Release/Box.obj b/cw 9/Release/Box.obj index 37c3eee..4fcca86 100644 Binary files a/cw 9/Release/Box.obj and b/cw 9/Release/Box.obj differ diff --git a/cw 9/Release/Camera.obj b/cw 9/Release/Camera.obj index d93af1f..308cd37 100644 Binary files a/cw 9/Release/Camera.obj and b/cw 9/Release/Camera.obj differ diff --git a/cw 9/Release/Render_Utils.obj b/cw 9/Release/Render_Utils.obj index 0ecf5cd..75737f1 100644 Binary files a/cw 9/Release/Render_Utils.obj and b/cw 9/Release/Render_Utils.obj differ diff --git a/cw 9/Release/SOIL.obj b/cw 9/Release/SOIL.obj index 2a4912a..87faa6f 100644 Binary files a/cw 9/Release/SOIL.obj and b/cw 9/Release/SOIL.obj differ diff --git a/cw 9/Release/Shader_Loader.obj b/cw 9/Release/Shader_Loader.obj index f1a59ab..2bc2c56 100644 Binary files a/cw 9/Release/Shader_Loader.obj and b/cw 9/Release/Shader_Loader.obj differ diff --git a/cw 9/Release/Texture.obj b/cw 9/Release/Texture.obj index f499932..74dd8d4 100644 Binary files a/cw 9/Release/Texture.obj and b/cw 9/Release/Texture.obj differ diff --git a/cw 9/Release/TriangleSoup.obj b/cw 9/Release/TriangleSoup.obj index 1d43ee4..a8ec373 100644 Binary files a/cw 9/Release/TriangleSoup.obj and b/cw 9/Release/TriangleSoup.obj differ diff --git a/cw 9/Release/grk-cw9.exe.recipe b/cw 9/Release/grk-cw9.exe.recipe index 310932f..bd4b977 100644 --- a/cw 9/Release/grk-cw9.exe.recipe +++ b/cw 9/Release/grk-cw9.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\jedrz\Desktop\grafika\GRK_Project\Release\grk-cw9.exe + C:\Users\jedrz\Desktop\graf\GRK_Project\Release\grk-cw9.exe diff --git a/cw 9/Release/grk-cw9.iobj b/cw 9/Release/grk-cw9.iobj index 52ce715..749c99f 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 a983835..7ab8499 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 6099c79..57910a9 100644 --- a/cw 9/Release/grk-cw9.log +++ b/cw 9/Release/grk-cw9.log @@ -1,60 +1,69 @@  main.cpp C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra -C:\Users\jedrz\Desktop\grafika\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\Collision_System.cpp(87,16): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\Collision_System.cpp(88,14): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\Collision_System.cpp(90,17): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\Collision_System.cpp(91,15): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\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\grafika\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\grafika\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\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(127,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(141,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(166,38): warning C4305: "=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(195,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(372,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(388,98): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(87,16): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(88,14): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(90,17): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(91,15): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\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\graf\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\graf\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\graf\GRK_Project\cw 9\src\ex_9_1.hpp(270,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(284,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(309,38): warning C4305: "=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(338,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(527,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(541,98): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(391,68): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(544,68): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(452,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(460,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(576,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(590,99): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(468,87): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(593,69): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(468,223): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(471,59): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(685,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(694,108): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(472,37): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(504,2): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(510,116): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(511,115): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(568,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(702,87): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(684,21): warning C4305: "-=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\grafika\GRK_Project\cw 9\src\ex_9_1.hpp(686,21): warning C4305: "+=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(702,223): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(705,59): warning C4305: "argument": obcięcie z "double" do "T" + with + [ + T=float + ] +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(706,37): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(726,2): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(825,108): warning C4305: "argument": obcięcie z "double" do "T" + with + [ + T=float + ] +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(1088,21): warning C4305: "-=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(1090,21): warning C4305: "+=": obcięcie z "double" do "float" Trwa generowanie kodu - 1 of 656 functions ( 0.2%) were compiled, the rest were copied from previous compilation. + 2 of 687 functions ( 0.3%) 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 + 10 functions had inline decision re-evaluated but remain unchanged Zakończono generowanie kodu - grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\grafika\GRK_Project\Release\grk-cw9.exe + grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\graf\GRK_Project\Release\grk-cw9.exe diff --git a/cw 9/Release/grk-cw9.tlog/CL.command.1.tlog b/cw 9/Release/grk-cw9.tlog/CL.command.1.tlog index b43badd..c23d77e 100644 Binary files a/cw 9/Release/grk-cw9.tlog/CL.command.1.tlog and b/cw 9/Release/grk-cw9.tlog/CL.command.1.tlog differ 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 06c7f34..197dcd5 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 ed8df15..f1ef338 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/grk-cw9.lastbuildstate b/cw 9/Release/grk-cw9.tlog/grk-cw9.lastbuildstate index 8102ff0..2a86d8e 100644 --- a/cw 9/Release/grk-cw9.tlog/grk-cw9.lastbuildstate +++ b/cw 9/Release/grk-cw9.tlog/grk-cw9.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0: -Release|Win32|C:\Users\jedrz\Desktop\grafika\GRK_Project\| +Release|Win32|C:\Users\jedrz\Desktop\graf\GRK_Project\| diff --git a/cw 9/Release/grk-cw9.tlog/link.command.1.tlog b/cw 9/Release/grk-cw9.tlog/link.command.1.tlog index 32c5c28..822e4cb 100644 Binary files a/cw 9/Release/grk-cw9.tlog/link.command.1.tlog and b/cw 9/Release/grk-cw9.tlog/link.command.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 16d2e38..1e885c7 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 d0f5b8c..600606f 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/image_DXT.obj b/cw 9/Release/image_DXT.obj index 5c9e942..ce9026c 100644 Binary files a/cw 9/Release/image_DXT.obj and b/cw 9/Release/image_DXT.obj differ diff --git a/cw 9/Release/image_helper.obj b/cw 9/Release/image_helper.obj index 81f435a..af5f580 100644 Binary files a/cw 9/Release/image_helper.obj and b/cw 9/Release/image_helper.obj differ diff --git a/cw 9/Release/main.obj b/cw 9/Release/main.obj index 7dceb49..964b711 100644 Binary files a/cw 9/Release/main.obj and b/cw 9/Release/main.obj differ diff --git a/cw 9/Release/stb_image_aug.obj b/cw 9/Release/stb_image_aug.obj index 0326112..4f7ae0e 100644 Binary files a/cw 9/Release/stb_image_aug.obj and b/cw 9/Release/stb_image_aug.obj differ diff --git a/cw 9/shaders/shader_9_1.frag b/cw 9/shaders/shader_9_1.frag index 69bea75..76aa573 100644 --- a/cw 9/shaders/shader_9_1.frag +++ b/cw 9/shaders/shader_9_1.frag @@ -4,12 +4,14 @@ float AMBIENT = 0.03; float PI = 3.14; uniform sampler2D depthMap; +uniform sampler2D depthMap2; uniform vec3 cameraPos; uniform vec3 color; uniform vec3 sunDir; +uniform vec3 sunDir2; uniform vec3 sunColor; uniform vec3 lightPos; @@ -38,6 +40,7 @@ in vec3 sunDirTS; in vec3 test; in vec4 sunSpacePos; +in vec4 sunSpacePos2; float DistributionGGX(vec3 normal, vec3 H, float roughness){ float a = roughness*roughness; @@ -112,6 +115,16 @@ float calculateShadow() { } } +float calculateShadow2() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5; + + float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} void main() { @@ -142,6 +155,8 @@ void main() //sun ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); + //sun2 + ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); //outColor = vec4(roughness,metallic,0,1); diff --git a/cw 9/shaders/shader_9_1.vert b/cw 9/shaders/shader_9_1.vert index 58c4888..ffce73c 100644 --- a/cw 9/shaders/shader_9_1.vert +++ b/cw 9/shaders/shader_9_1.vert @@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; uniform mat4 LightVP; +uniform mat4 LightVP2; out vec3 vecNormal; out vec3 worldPos; @@ -23,6 +24,7 @@ out vec3 lightDirTS; out vec3 spotlightDirTS; out vec3 sunDirTS; out vec4 sunSpacePos; +out vec4 sunSpacePos2; void main() { @@ -42,4 +44,5 @@ void main() spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); + sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); } diff --git a/cw 9/shaders/shader_tex.frag b/cw 9/shaders/shader_tex.frag index 0fe13d3..0b9b88c 100644 --- a/cw 9/shaders/shader_tex.frag +++ b/cw 9/shaders/shader_tex.frag @@ -4,12 +4,14 @@ float AMBIENT = 0.03; float PI = 3.14; uniform sampler2D depthMap; +uniform sampler2D depthMap2; uniform vec3 cameraPos; uniform sampler2D colorTexture; uniform vec3 sunDir; +uniform vec3 sunDir2; uniform vec3 sunColor; uniform vec3 lightPos; @@ -39,6 +41,7 @@ in vec3 spotlightDirTS; in vec3 sunDirTS; in vec4 sunSpacePos; +in vec4 sunSpacePos2; vec3 color; @@ -114,6 +117,16 @@ float calculateShadow() { return (0.5*(diff)/abs(diff))+0.5; } +float calculateShadow2() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5; + + float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} void main() { @@ -148,6 +161,8 @@ void main() //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); + //sun2 + ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); } \ No newline at end of file diff --git a/cw 9/shaders/shader_tex.vert b/cw 9/shaders/shader_tex.vert index 05f1647..869afa1 100644 --- a/cw 9/shaders/shader_tex.vert +++ b/cw 9/shaders/shader_tex.vert @@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; uniform mat4 LightVP; +uniform mat4 LightVP2; out vec3 vecNormal; out vec3 worldPos; @@ -24,6 +25,8 @@ out vec3 spotlightDirTS; out vec3 sunDirTS; out vec2 vecTex; out vec4 sunSpacePos; +out vec4 sunSpacePos2; + void main() { @@ -46,5 +49,6 @@ void main() spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); + sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); } \ No newline at end of file diff --git a/cw 9/shaders/shader_tex_pbr.frag b/cw 9/shaders/shader_tex_pbr.frag index 4246280..ae5561e 100644 --- a/cw 9/shaders/shader_tex_pbr.frag +++ b/cw 9/shaders/shader_tex_pbr.frag @@ -8,6 +8,7 @@ float PI = 3.14; uniform vec3 cameraPos; uniform sampler2D depthMap; +uniform sampler2D depthMap2; uniform sampler2D colorTexture; uniform sampler2D metallicTexture; uniform sampler2D roughnessTexture; @@ -15,6 +16,7 @@ uniform sampler2D aoTexture; uniform sampler2D normalSampler; uniform vec3 sunDir; +uniform vec3 sunDir2; uniform vec3 sunColor; uniform vec3 lightPos; @@ -46,6 +48,7 @@ float metallic; float roughness; in vec4 sunSpacePos; +in vec4 sunSpacePos2; float DistributionGGX(vec3 normal, vec3 H, float roughness){ @@ -119,6 +122,17 @@ float calculateShadow() { return (0.5*(diff)/abs(diff))+0.5; } +float calculateShadow2() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5; + + float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} + void main() { @@ -157,6 +171,9 @@ void main() //sun //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); - + //outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); + + //sun2 + ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); } \ No newline at end of file diff --git a/cw 9/shaders/shader_tex_pbr.vert b/cw 9/shaders/shader_tex_pbr.vert index 4258289..7485d32 100644 --- a/cw 9/shaders/shader_tex_pbr.vert +++ b/cw 9/shaders/shader_tex_pbr.vert @@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; uniform mat4 LightVP; +uniform mat4 LightVP2; out vec3 vecNormal; out vec3 worldPos; @@ -24,6 +25,8 @@ out vec3 spotlightDirTS; out vec3 sunDirTS; out vec2 vecTex; out vec4 sunSpacePos; +out vec4 sunSpacePos2; + void main() { @@ -45,5 +48,6 @@ void main() spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); + sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); } diff --git a/cw 9/shaders/shader_tex_pbr_arm.frag b/cw 9/shaders/shader_tex_pbr_arm.frag index 2d440a8..bf8dfbf 100644 --- a/cw 9/shaders/shader_tex_pbr_arm.frag +++ b/cw 9/shaders/shader_tex_pbr_arm.frag @@ -8,11 +8,13 @@ float PI = 3.14; uniform vec3 cameraPos; uniform sampler2D depthMap; +uniform sampler2D depthMap2; uniform sampler2D colorTexture; uniform sampler2D armTexture; uniform sampler2D normalSampler; uniform vec3 sunDir; +uniform vec3 sunDir2; uniform vec3 sunColor; uniform vec3 lightPos; @@ -44,6 +46,7 @@ float metallic; float roughness; in vec4 sunSpacePos; +in vec4 sunSpacePos2; float DistributionGGX(vec3 normal, vec3 H, float roughness){ @@ -118,6 +121,17 @@ float calculateShadow() { } +float calculateShadow2() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5; + + float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} + void main() { color = texture2D(colorTexture, vecTex).xyz; @@ -155,6 +169,9 @@ void main() //sun //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); + + //sun2 + ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); } \ No newline at end of file diff --git a/cw 9/shaders/shader_tex_pbr_arm.vert b/cw 9/shaders/shader_tex_pbr_arm.vert index 4258289..53d5f74 100644 --- a/cw 9/shaders/shader_tex_pbr_arm.vert +++ b/cw 9/shaders/shader_tex_pbr_arm.vert @@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; uniform mat4 LightVP; +uniform mat4 LightVP2; out vec3 vecNormal; out vec3 worldPos; @@ -24,6 +25,7 @@ out vec3 spotlightDirTS; out vec3 sunDirTS; out vec2 vecTex; out vec4 sunSpacePos; +out vec4 sunSpacePos2; void main() { @@ -45,5 +47,6 @@ void main() spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); + sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); } diff --git a/cw 9/sound/ocean.wav b/cw 9/sound/ocean.wav new file mode 100644 index 0000000..37a816e Binary files /dev/null and b/cw 9/sound/ocean.wav differ diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index 9207f3f..0272ade 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -20,7 +20,7 @@ const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; -int WIDTH = 500, HEIGHT = 500; +int WIDTH = 1000, HEIGHT = 1000; CollisionSystem collisionSystem; @@ -70,8 +70,14 @@ namespace models { Core::RenderContext couchContext; Core::RenderContext vaseContext; + Core::RenderContext laptopContext; + Core::RenderContext screenContext; - + Core::RenderContext mugContext; + Core::RenderContext carContext; + Core::RenderContext books1Context; + Core::RenderContext books2Context; + Core::RenderContext cactusContext; } std::vector faces = { @@ -178,10 +184,43 @@ namespace texture { GLuint vase_albedo; GLuint vase_arm; GLuint vase_normal; + + GLuint laptop_albedo; + GLuint laptop_metallic; + GLuint laptop_roughness; + GLuint laptop_ao; + GLuint laptop_normal; + + GLuint mug_albedo; + GLuint mug_metallic; + GLuint mug_roughness; + GLuint mug_ao; + GLuint mug_normal; + + GLuint car_albedo; + GLuint car_metallic; + GLuint car_roughness; + GLuint car_ao; + GLuint car_normal; + + GLuint books_albedo; + GLuint books_metallic; + GLuint books_roughness; + GLuint books_ao; + GLuint books_normal; + + GLuint cactus_albedo; + GLuint cactus_metallic; + GLuint cactus_roughness; + GLuint cactus_ao; + GLuint cactus_normal; + } GLuint depthMapFBO; GLuint depthMap; +GLuint depthMapFBO2; +GLuint depthMap2; GLuint program; GLuint programSun; @@ -201,15 +240,17 @@ Core::RenderContext shipContext; Core::RenderContext sphereContext; TriangleSoup water; -glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f); +glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, -0.069280f); glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f); +glm::vec3 sunPos2 = glm::vec3(4.040971f, 2.149999f, -0.739280f); +glm::vec3 sunDir2 = glm::vec3(0.93633f, 0.351106, -0.003226f); glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5; glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f); glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f); -glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f); +glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -1.189549f); glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f); GLuint VAO, VBO; @@ -217,6 +258,9 @@ float aspectRatio = 1.f; float exposition = 1.f; +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::vec3 pointlightPos = glm::vec3(0, 2, 0); glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); @@ -325,6 +369,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z); + glUniform3f(glGetUniformLocation(program, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z); glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); @@ -335,9 +380,11 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z); glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi); - 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)); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP); Core::SetActiveTexture(depthMap, "depthMap", program, 0); + glUniformMatrix4fv(glGetUniformLocation(program, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); + Core::SetActiveTexture(depthMap2, "depthMap2", program, 1); Core::DrawContext(context); } @@ -359,6 +406,7 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTex, "sunDir"), sunDir.x, sunDir.y, sunDir.z); + glUniform3f(glGetUniformLocation(programTex, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z); glUniform3f(glGetUniformLocation(programTex, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); @@ -372,9 +420,11 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro //Core::DrawContext(context); - 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)); + glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP"), 1, GL_FALSE, (float*)&lightVP); Core::SetActiveTexture(depthMap, "depthMap", programTex, 1); + glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); + Core::SetActiveTexture(depthMap2, "depthMap2", programTex, 2); Core::DrawContext(context); } @@ -396,6 +446,7 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin glUniform3f(glGetUniformLocation(programTexPBR, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTexPBR, "sunDir"), sunDir.x, sunDir.y, sunDir.z); + glUniform3f(glGetUniformLocation(programTexPBR, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z); glUniform3f(glGetUniformLocation(programTexPBR, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTexPBR, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); @@ -413,9 +464,11 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin //Core::DrawContext(context); - 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)); + glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP"), 1, GL_FALSE, (float*)&lightVP); Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0); + glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); + Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR, 6); Core::DrawContext(context); } @@ -437,6 +490,7 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G glUniform3f(glGetUniformLocation(programTexPBR_ARM, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunDir"), sunDir.x, sunDir.y, sunDir.z); + glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); @@ -452,9 +506,11 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G //Core::DrawContext(context); - 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)); + glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP"), 1, GL_FALSE, (float*)&lightVP); Core::SetActiveTexture(depthMap, "depthMap", programTexPBR_ARM, 0); + glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2); + Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR_ARM, 4); Core::DrawContext(context); } @@ -482,29 +538,85 @@ void renderShadowapSun() { //ustawianie programu glUseProgram(programDepth); - 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)); - drawObjectDepth(sphereContext, lightVP, 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, lightVP, 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, lightVP, glm::mat4()); - drawObjectDepth(models::chairContext, lightVP, glm::mat4()); - drawObjectDepth(models::deskContext, lightVP, glm::mat4()); + drawObjectDepth(models::mattressContext, lightVP, glm::mat4()); + drawObjectDepth(models::bed_pillowContext, lightVP, glm::mat4()); + drawObjectDepth(models::floorContext, lightVP, glm::mat4()); + drawObjectDepth(models::desk_topContext, lightVP, glm::mat4()); + drawObjectDepth(models::desk_bottomContext, lightVP, glm::mat4()); + drawObjectDepth(models::framesContext, lightVP, glm::mat4()); + drawObjectDepth(models::wallContext, lightVP, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP, glm::mat4()); + drawObjectDepth(models::couchContext, lightVP, glm::mat4()); + drawObjectDepth(models::laptopContext, lightVP, glm::mat4()); drawObjectDepth(models::doorContext, lightVP, glm::mat4()); + drawObjectDepth(models::chairContext, lightVP, glm::mat4()); + drawObjectDepth(models::roofContext, lightVP, glm::mat4()); + drawObjectDepth(models::blanketContext, lightVP, glm::mat4()); drawObjectDepth(models::drawerContext, lightVP, glm::mat4()); - drawObjectDepth(models::marbleBustContext, lightVP, glm::translate(glm::mat4(), glm::vec3(0, 0, -0.2))); - drawObjectDepth(models::marbleBustContext, lightVP, glm::translate(glm::mat4(), glm::vec3(0, 0, 0.2))); - drawObjectDepth(models::materaceContext, lightVP, glm::mat4()); - drawObjectDepth(models::pencilsContext, lightVP, glm::mat4()); - drawObjectDepth(models::planeContext, lightVP, glm::mat4()); - drawObjectDepth(models::roomContext, lightVP, glm::mat4()); - drawObjectDepth(models::windowContext, lightVP, glm::mat4()); + drawObjectDepth(models::clockContext, lightVP, glm::mat4()); + drawObjectDepth(models::plantContext, lightVP, glm::mat4()); + drawObjectDepth(models::c_tableContext, lightVP, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP, glm::mat4()); + drawObjectDepth(models::mugContext, lightVP, glm::mat4()); + drawObjectDepth(models::carContext, lightVP, glm::mat4()); + drawObjectDepth(models::books1Context, lightVP, glm::mat4()); + drawObjectDepth(models::books2Context, lightVP, glm::mat4()); + drawObjectDepth(models::cactusContext, lightVP, glm::mat4()); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glViewport(0, 0, WIDTH, HEIGHT); +} +void renderShadowapSun2() { + 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, depthMapFBO2); + //czyszczenie mapy głębokości + glClear(GL_DEPTH_BUFFER_BIT); + //ustawianie programu + glUseProgram(programDepth); + drawObjectDepth(sphereContext, lightVP2, 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, + lightVP2, 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, lightVP2, glm::mat4()); + drawObjectDepth(models::mattressContext, lightVP2, glm::mat4()); + drawObjectDepth(models::bed_pillowContext, lightVP2, glm::mat4()); + drawObjectDepth(models::floorContext, lightVP2, glm::mat4()); + drawObjectDepth(models::desk_topContext, lightVP2, glm::mat4()); + drawObjectDepth(models::desk_bottomContext, lightVP2, glm::mat4()); + drawObjectDepth(models::framesContext, lightVP2, glm::mat4()); + drawObjectDepth(models::wallContext, lightVP2, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP2, glm::mat4()); + drawObjectDepth(models::couchContext, lightVP2, glm::mat4()); + drawObjectDepth(models::laptopContext, lightVP2, glm::mat4()); + drawObjectDepth(models::doorContext, lightVP2, glm::mat4()); + drawObjectDepth(models::chairContext, lightVP2, glm::mat4()); + drawObjectDepth(models::roofContext, lightVP2, glm::mat4()); + drawObjectDepth(models::blanketContext, lightVP2, glm::mat4()); + drawObjectDepth(models::drawerContext, lightVP2, glm::mat4()); + drawObjectDepth(models::clockContext, lightVP2, glm::mat4()); + drawObjectDepth(models::plantContext, lightVP2, glm::mat4()); + drawObjectDepth(models::c_tableContext, lightVP2, glm::mat4()); + drawObjectDepth(models::foldingContext, lightVP2, glm::mat4()); + drawObjectDepth(models::mugContext, lightVP2, glm::mat4()); + drawObjectDepth(models::carContext, lightVP2, glm::mat4()); + drawObjectDepth(models::books1Context, lightVP2, glm::mat4()); + drawObjectDepth(models::books2Context, lightVP2, glm::mat4()); + drawObjectDepth(models::cactusContext, lightVP2, glm::mat4()); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, WIDTH, HEIGHT); } @@ -529,6 +641,26 @@ void initDepthMap() glBindFramebuffer(GL_FRAMEBUFFER, 0); } +void initDepthMap2() +{ + glGenFramebuffers(1, &depthMapFBO2); + + glGenTextures(1, &depthMap2); + glBindTexture(GL_TEXTURE_2D, depthMap2); + 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, depthMapFBO2); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap2, 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())); @@ -554,6 +686,7 @@ void renderScene(GLFWwindow* window) updateDeltaTime(time); renderShadowapSun(); + renderShadowapSun2(); //space lamp glUseProgram(programSun); @@ -572,18 +705,6 @@ void renderScene(GLFWwindow* window) 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)), glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0); - //drawObjectPBR(models::bedContext, glm::mat4(), glm::vec3(0.03f, 0.03f, 0.03f), 0.2f, 0.0f); - //drawObjectPBR(models::chairContext, glm::mat4(), glm::vec3(0.195239f, 0.37728f, 0.8f), 0.4f, 0.0f); - //drawObjectPBR(models::deskContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f); - //drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f); - //drawObjectPBR(models::drawerContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f); - //drawObjectPBR(models::marbleBustContext, glm::mat4(), glm::vec3(1.f, 1.f, 1.f), 0.5f, 1.0f); - //drawObjectPBR(models::materaceContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f); - //drawObjectPBR(models::pencilsContext, glm::mat4(), glm::vec3(0.10039f, 0.018356f, 0.001935f), 0.1f, 0.0f); - //drawObjectPBR(models::planeContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f); - //drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f); - //drawObjectPBR(models::windowContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f); - glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f))); glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir)); glm::mat4 specshipCameraRotrationMatrix = glm::mat4({ @@ -611,6 +732,7 @@ void renderScene(GLFWwindow* window) //drawObjectTex(models::marbleBustContext, glm::translate(glm::mat4(), glm::vec3(0, 0, -0.2)), 0.2, 0, texture::rust); //drawObjectTex(models::marbleBustContext, glm::translate(glm::mat4(), glm::vec3(0, 0, 0.2)), 0, 0.2, texture::rust); //drawObjectTex(models::doorContext, glm::mat4(), 0, 0, texture::screen); + drawObjectTex(models::screenContext, glm::mat4(), 0, 0, texture::screen); glUseProgram(programTexPBR); //drawObjectTexPBR(models::deskContext, glm::mat4(), texture::table_roughness, texture::table_metallic, texture::table_albedo, texture::table_normal, texture::table_ao); @@ -627,7 +749,12 @@ void renderScene(GLFWwindow* window) drawObjectTexPBR(models::couchContext, glm::mat4(), texture::couch_roughness, texture::couch_metallic, texture::couch_albedo, texture::couch_normal, texture::couch_ao); drawObjectTexPBR(models::doorContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao); drawObjectTexPBR(models::chairContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao); - + drawObjectTexPBR(models::laptopContext, glm::mat4(), texture::laptop_roughness, texture::laptop_metallic, texture::laptop_albedo, texture::laptop_normal, texture::laptop_ao); + drawObjectTexPBR(models::mugContext, glm::mat4(), texture::mug_roughness, texture::mug_metallic, texture::mug_albedo, texture::mug_normal, texture::mug_ao); + drawObjectTexPBR(models::carContext, glm::mat4(), texture::car_roughness, texture::car_metallic, texture::car_albedo, texture::car_normal, texture::car_ao); + drawObjectTexPBR(models::cactusContext, glm::mat4(), texture::cactus_roughness, texture::cactus_metallic, texture::cactus_albedo, texture::cactus_normal, texture::cactus_ao); + drawObjectTexPBR(models::books1Context, glm::mat4(), texture::books_roughness, texture::books_metallic, texture::books_albedo, texture::books_normal, texture::books_ao); + drawObjectTexPBR(models::books2Context, glm::mat4(), texture::books_roughness, texture::books_metallic, texture::books_albedo, texture::books_normal, texture::books_ao); @@ -647,18 +774,6 @@ void renderScene(GLFWwindow* window) drawObjectTexPBR_ARM(models::vaseContext, glm::mat4(), texture::vase_albedo, texture::vase_normal, texture::vase_arm); - - - - - - - - - - - - glUseProgram(programWater); //drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0, -1.0, 0.0)) * glm::scale(glm::vec3(30.0)), glm::vec3(0.1, 0.1, 0.95), time, texture::water); drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0f, -1.7f, 0.0f)), glm::vec4(0.1, 0.1, 0.95, 0.5), time, texture::water); @@ -710,6 +825,8 @@ void init(GLFWwindow* window) glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); initDepthMap(); + initDepthMap2(); + 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"); programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag"); @@ -820,7 +937,36 @@ void init(GLFWwindow* window) texture::vase_arm = Core::LoadTexture("textures/vase/arm.png"); texture::vase_normal = Core::LoadTexture("textures/vase/normal.png"); + texture::laptop_albedo = Core::LoadTexture("textures/laptop/albedo.png"); + texture::laptop_metallic = Core::LoadTexture("textures/laptop/metallic.png"); + texture::laptop_roughness = Core::LoadTexture("textures/laptop/roughness.png"); + texture::laptop_ao = Core::LoadTexture("textures/laptop/ao.png"); + texture::laptop_normal = Core::LoadTexture("textures/laptop/normal.png"); + texture::screen = Core::LoadTexture("textures/visual.png"); + texture::mug_albedo = Core::LoadTexture("textures/mug/albedo.png"); + texture::mug_metallic = Core::LoadTexture("textures/mug/metallic.png"); + texture::mug_roughness = Core::LoadTexture("textures/mug/roughness.png"); + texture::mug_ao = Core::LoadTexture("textures/mug/ao.png"); + texture::mug_normal = Core::LoadTexture("textures/mug/normal.png"); + + texture::car_albedo = Core::LoadTexture("textures/car/albedo.jpg"); + texture::car_metallic = Core::LoadTexture("textures/car/metallic.jpg"); + texture::car_roughness = Core::LoadTexture("textures/car/roughness.jpg"); + texture::car_ao = Core::LoadTexture("textures/car/ao.jpg"); + texture::car_normal = Core::LoadTexture("textures/car/normal.jpg"); + + texture::books_albedo = Core::LoadTexture("textures/books/albedo.png"); + texture::books_metallic = Core::LoadTexture("textures/books/metallic.png"); + texture::books_roughness = Core::LoadTexture("textures/books/roughness.png"); + texture::books_ao = Core::LoadTexture("textures/books/ao.png"); + texture::books_normal = Core::LoadTexture("textures/books/normal.png"); + + texture::cactus_albedo = Core::LoadTexture("textures/cactus/albedo.png"); + texture::cactus_metallic = Core::LoadTexture("textures/cactus/metallic.png"); + texture::cactus_roughness = Core::LoadTexture("textures/cactus/roughness.png"); + texture::cactus_ao = Core::LoadTexture("textures/cactus/ao.png"); + texture::cactus_normal = Core::LoadTexture("textures/cactus/normal.png"); loadModelToContext("./models/sphere.obj", sphereContext, false); loadModelToContext("./models/spaceship.obj", shipContext, false); @@ -840,32 +986,40 @@ void init(GLFWwindow* window) loadModelToContext("./models/test.obj", models::testContext, false); loadModelToContext("./models/cube.obj", models::cubeContext, false); //loadModelToContext("./models/table.obj", models::tableContext, false); - loadModelToContext("./models/wall.obj", models::wallContext, true); - loadModelToContext("./models/roof.obj", models::roofContext, true); + loadModelToContext("./models/wall.obj", models::wallContext, false); + loadModelToContext("./models/roof.obj", models::roofContext, false); loadModelToContext("./models/window.obj", models::windowContext, true); loadModelToContext("./models/ground.obj", models::floorContext, false); loadModelToContext("./models/ground_001.obj", models::ceilingContext, false); - loadModelToContext("./models/bed_frame.obj", models::bedContext, false); - loadModelToContext("./models/bed_mattress.obj", models::mattressContext, false); + loadModelToContext("./models/bed_frame.obj", models::bedContext, true); + loadModelToContext("./models/bed_mattress.obj", models::mattressContext, true); loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false); - loadModelToContext("./models/paplan.obj", models::blanketContext, true); + loadModelToContext("./models/paplan.obj", models::blanketContext, false); - loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, false); + loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, true); 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); loadModelToContext("./models/windows_v.obj", models::framesContext, false); - loadModelToContext("./models/Cylinder.obj", models::trashcanContext, true); + loadModelToContext("./models/Cylinder.obj", models::trashcanContext, false); loadModelToContext("./models/drawer_cabinet.obj", models::drawerContext, true); - loadModelToContext("./models/alarm_clock_01.obj", models::clockContext, true); - loadModelToContext("./models/potted_plant_04.obj", models::plantContext, true); - loadModelToContext("./models/modern_coffee_table_01.obj", models::c_tableContext, true); - loadModelToContext("./models/20848_Folding_Screen_v3.obj", models::foldingContext, false); + loadModelToContext("./models/alarm_clock_01.obj", models::clockContext, false); + loadModelToContext("./models/potted_plant_04.obj", models::plantContext, false); + loadModelToContext("./models/modern_coffee_table_01.obj", models::c_tableContext, false); + loadModelToContext("./models/20848_Folding_Screen_v3.obj", models::foldingContext, true); loadModelToContext("./models/Foot_Rest_001.obj", models::couchContext, false); loadModelToContext("./models/dor.obj", models::doorContext, false); loadModelToContext("./models/uploads_files_1938755_KAUSTBY.obj", models::chairContext, false); - loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, true); - //collisionSystem.calculateSceneBounding(); + loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, false); + loadModelToContext("./models/laptop.obj", models::laptopContext, false); + loadModelToContext("./models/screen.obj", models::screenContext, false); + loadModelToContext("./models/mug.obj", models::mugContext, false); + loadModelToContext("./models/car.obj", models::carContext, false); + loadModelToContext("./models/cactus.obj", models::cactusContext, false); + loadModelToContext("./models/books1.obj", models::books1Context, false); + loadModelToContext("./models/books2.obj", models::books2Context, false); + + collisionSystem.calculateSceneBounding(); skyboxTexture = loadSkybox(faces); //drawSkybox(models::cubeContext, transformation, skyboxTexture); @@ -911,8 +1065,16 @@ void processInput(GLFWwindow* window) PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC); } if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) { + texture::screen = Core::LoadTexture("textures/heroes.jpg"); + PlaySound(TEXT("sound/grass.wav"), NULL, SND_ASYNC); + } + if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) { + texture::screen = Core::LoadTexture("textures/necro.png"); + PlaySound(TEXT("sound/necro.wav"), NULL, SND_ASYNC); + } + if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) { texture::screen = Core::LoadTexture("textures/visual.png"); - PlaySound(nullptr, nullptr, 0); + PlaySound(TEXT("sound/ocean.wav"), NULL, SND_ASYNC|SND_LOOP); } cameraDir = spaceshipDir; diff --git a/cw 9/src/main.cpp b/cw 9/src/main.cpp index 0a6a4b3..ea11ebb 100644 --- a/cw 9/src/main.cpp +++ b/cw 9/src/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char** argv) #endif // tworzenie okna za pomoca glfw - GLFWwindow* window = glfwCreateWindow(500, 500, "FirstWindow", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(1000, 1000, "FirstWindow", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; @@ -35,7 +35,7 @@ int main(int argc, char** argv) // ladowanie OpenGL za pomoca glew glewInit(); - glViewport(0, 0, 500, 500); + glViewport(0, 0, 1000, 1000); init(window); diff --git a/cw 9/textures/books/albedo.png b/cw 9/textures/books/albedo.png new file mode 100644 index 0000000..440ad9f Binary files /dev/null and b/cw 9/textures/books/albedo.png differ diff --git a/cw 9/textures/books/ao.png b/cw 9/textures/books/ao.png new file mode 100644 index 0000000..12b06b5 Binary files /dev/null and b/cw 9/textures/books/ao.png differ diff --git a/cw 9/textures/books/metallic.png b/cw 9/textures/books/metallic.png new file mode 100644 index 0000000..e1c6989 Binary files /dev/null and b/cw 9/textures/books/metallic.png differ diff --git a/cw 9/textures/books/normal.png b/cw 9/textures/books/normal.png new file mode 100644 index 0000000..d1ab9f2 Binary files /dev/null and b/cw 9/textures/books/normal.png differ diff --git a/cw 9/textures/books/roughness.png b/cw 9/textures/books/roughness.png new file mode 100644 index 0000000..fb7ba35 Binary files /dev/null and b/cw 9/textures/books/roughness.png differ diff --git a/cw 9/textures/cactus/albedo.png b/cw 9/textures/cactus/albedo.png new file mode 100644 index 0000000..561a30c Binary files /dev/null and b/cw 9/textures/cactus/albedo.png differ diff --git a/cw 9/textures/cactus/ao.png b/cw 9/textures/cactus/ao.png new file mode 100644 index 0000000..f20e700 Binary files /dev/null and b/cw 9/textures/cactus/ao.png differ diff --git a/cw 9/textures/cactus/metallic.png b/cw 9/textures/cactus/metallic.png new file mode 100644 index 0000000..b126d24 Binary files /dev/null and b/cw 9/textures/cactus/metallic.png differ diff --git a/cw 9/textures/cactus/normal.png b/cw 9/textures/cactus/normal.png new file mode 100644 index 0000000..e04df76 Binary files /dev/null and b/cw 9/textures/cactus/normal.png differ diff --git a/cw 9/textures/cactus/roughness.png b/cw 9/textures/cactus/roughness.png new file mode 100644 index 0000000..f20e700 Binary files /dev/null and b/cw 9/textures/cactus/roughness.png differ diff --git a/cw 9/textures/car/albedo.jpg b/cw 9/textures/car/albedo.jpg new file mode 100644 index 0000000..c4c4a2f Binary files /dev/null and b/cw 9/textures/car/albedo.jpg differ diff --git a/cw 9/textures/car/ao.jpg b/cw 9/textures/car/ao.jpg new file mode 100644 index 0000000..8797740 Binary files /dev/null and b/cw 9/textures/car/ao.jpg differ diff --git a/cw 9/textures/car/metallic.jpg b/cw 9/textures/car/metallic.jpg new file mode 100644 index 0000000..b5deec6 Binary files /dev/null and b/cw 9/textures/car/metallic.jpg differ diff --git a/cw 9/textures/car/normal.jpg b/cw 9/textures/car/normal.jpg new file mode 100644 index 0000000..c0e1953 Binary files /dev/null and b/cw 9/textures/car/normal.jpg differ diff --git a/cw 9/textures/car/roughness.jpg b/cw 9/textures/car/roughness.jpg new file mode 100644 index 0000000..1341506 Binary files /dev/null and b/cw 9/textures/car/roughness.jpg differ diff --git a/cw 9/textures/car/wooden_car_toy_glossiness.jpg b/cw 9/textures/car/wooden_car_toy_glossiness.jpg new file mode 100644 index 0000000..3792561 Binary files /dev/null and b/cw 9/textures/car/wooden_car_toy_glossiness.jpg differ diff --git a/cw 9/textures/floor3/albedo.jpg b/cw 9/textures/floor3/albedo.jpg new file mode 100644 index 0000000..2071684 Binary files /dev/null and b/cw 9/textures/floor3/albedo.jpg differ diff --git a/cw 9/textures/floor3/ao.jpg b/cw 9/textures/floor3/ao.jpg new file mode 100644 index 0000000..0cce3ce Binary files /dev/null and b/cw 9/textures/floor3/ao.jpg differ diff --git a/cw 9/textures/floor3/metallic.jpg b/cw 9/textures/floor3/metallic.jpg new file mode 100644 index 0000000..a0337e3 Binary files /dev/null and b/cw 9/textures/floor3/metallic.jpg differ diff --git a/cw 9/textures/floor3/normal.jpg b/cw 9/textures/floor3/normal.jpg new file mode 100644 index 0000000..14f8104 Binary files /dev/null and b/cw 9/textures/floor3/normal.jpg differ diff --git a/cw 9/textures/floor3/roughness.jpg b/cw 9/textures/floor3/roughness.jpg new file mode 100644 index 0000000..2f71b37 Binary files /dev/null and b/cw 9/textures/floor3/roughness.jpg differ diff --git a/cw 9/textures/floor4/albedo.jpg b/cw 9/textures/floor4/albedo.jpg new file mode 100644 index 0000000..b8c2272 Binary files /dev/null and b/cw 9/textures/floor4/albedo.jpg differ diff --git a/cw 9/textures/floor4/ao.jpg b/cw 9/textures/floor4/ao.jpg new file mode 100644 index 0000000..52d37dd Binary files /dev/null and b/cw 9/textures/floor4/ao.jpg differ diff --git a/cw 9/textures/floor4/metallic.jpg b/cw 9/textures/floor4/metallic.jpg new file mode 100644 index 0000000..f30de47 Binary files /dev/null and b/cw 9/textures/floor4/metallic.jpg differ diff --git a/cw 9/textures/floor4/normal.jpg b/cw 9/textures/floor4/normal.jpg new file mode 100644 index 0000000..b7d2b7c Binary files /dev/null and b/cw 9/textures/floor4/normal.jpg differ diff --git a/cw 9/textures/floor4/roughness.jpg b/cw 9/textures/floor4/roughness.jpg new file mode 100644 index 0000000..91b6c61 Binary files /dev/null and b/cw 9/textures/floor4/roughness.jpg differ diff --git a/cw 9/textures/laptop/albedo.png b/cw 9/textures/laptop/albedo.png new file mode 100644 index 0000000..7014f65 Binary files /dev/null and b/cw 9/textures/laptop/albedo.png differ diff --git a/cw 9/textures/laptop/ao.png b/cw 9/textures/laptop/ao.png new file mode 100644 index 0000000..97855dc Binary files /dev/null and b/cw 9/textures/laptop/ao.png differ diff --git a/cw 9/textures/laptop/metallic.png b/cw 9/textures/laptop/metallic.png new file mode 100644 index 0000000..e851639 Binary files /dev/null and b/cw 9/textures/laptop/metallic.png differ diff --git a/cw 9/textures/laptop/normal.png b/cw 9/textures/laptop/normal.png new file mode 100644 index 0000000..ecb76a1 Binary files /dev/null and b/cw 9/textures/laptop/normal.png differ diff --git a/cw 9/textures/laptop/roughness.png b/cw 9/textures/laptop/roughness.png new file mode 100644 index 0000000..e387f35 Binary files /dev/null and b/cw 9/textures/laptop/roughness.png differ diff --git a/cw 9/textures/mug/albedo.png b/cw 9/textures/mug/albedo.png new file mode 100644 index 0000000..1326759 Binary files /dev/null and b/cw 9/textures/mug/albedo.png differ diff --git a/cw 9/textures/mug/ao.png b/cw 9/textures/mug/ao.png new file mode 100644 index 0000000..fc5e6e5 Binary files /dev/null and b/cw 9/textures/mug/ao.png differ diff --git a/cw 9/textures/mug/metallic.png b/cw 9/textures/mug/metallic.png new file mode 100644 index 0000000..aa28098 Binary files /dev/null and b/cw 9/textures/mug/metallic.png differ diff --git a/cw 9/textures/mug/normal.png b/cw 9/textures/mug/normal.png new file mode 100644 index 0000000..b74c694 Binary files /dev/null and b/cw 9/textures/mug/normal.png differ diff --git a/cw 9/textures/mug/roughness.png b/cw 9/textures/mug/roughness.png new file mode 100644 index 0000000..8dae02a Binary files /dev/null and b/cw 9/textures/mug/roughness.png differ diff --git a/models.txt b/models.txt new file mode 100644 index 0000000..e5268a3 --- /dev/null +++ b/models.txt @@ -0,0 +1 @@ +https://drive.google.com/drive/folders/1H9mCPv32GYCW7wTFX0St0C-mWTQPUpZ-?usp=sharing \ No newline at end of file