diff --git a/Release/grk-cw9.exe b/Release/grk-cw9.exe index e6794eb..d0a264a 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 ed08ad9..73f6f3e 100644 Binary files a/Release/grk-cw9.pdb and b/Release/grk-cw9.pdb differ diff --git a/cw 9/Release/Texture.obj b/cw 9/Release/Texture.obj index 286f62c..16b90df 100644 Binary files a/cw 9/Release/Texture.obj and b/cw 9/Release/Texture.obj differ diff --git a/cw 9/Release/grk-cw9.iobj b/cw 9/Release/grk-cw9.iobj index aca10ed..bd0d34e 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 f5cd854..bbf67ad 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 f5dc1dd..aa22dd7 100644 --- a/cw 9/Release/grk-cw9.log +++ b/cw 9/Release/grk-cw9.log @@ -1,52 +1,52 @@  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\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(104,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(118,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(143,38): warning C4305: "=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(172,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(308,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(324,98): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(122,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(136,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(161,38): warning C4305: "=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(190,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(328,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(344,98): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(327,68): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(347,68): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(388,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(396,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(408,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(416,108): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(404,87): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(424,87): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(404,223): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(407,59): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(424,223): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(427,59): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(408,37): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(441,2): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(447,116): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(448,113): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(496,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(428,37): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(461,2): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(467,116): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(468,113): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(519,108): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(581,21): warning C4305: "-=": obcięcie z "double" do "float" -C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(583,21): warning C4305: "+=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(631,21): warning C4305: "-=": obcięcie z "double" do "float" +C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(633,21): warning C4305: "+=": obcięcie z "double" do "float" Trwa generowanie kodu 4 of 604 functions ( 0.7%) were compiled, the rest were copied from previous compilation. 0 functions were new in current compilation - 9 functions had inline decision re-evaluated but remain unchanged + 6 functions had inline decision re-evaluated but remain unchanged Zakończono generowanie kodu grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\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 cd0f570..fdfee7b 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 8c562d7..376dfdf 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 adc52dd..a9bd598 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.command.1.tlog b/cw 9/Release/grk-cw9.tlog/link.command.1.tlog index 7233408..d647cf9 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 652f838..2869610 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/main.obj b/cw 9/Release/main.obj index 12c0486..d08bc61 100644 Binary files a/cw 9/Release/main.obj and b/cw 9/Release/main.obj differ diff --git a/cw 9/Release/vc143.pdb b/cw 9/Release/vc143.pdb index 99208f8..84b14fd 100644 Binary files a/cw 9/Release/vc143.pdb and b/cw 9/Release/vc143.pdb differ diff --git a/cw 9/grk-cw9.vcxproj b/cw 9/grk-cw9.vcxproj index 84bc5c2..89424ab 100644 --- a/cw 9/grk-cw9.vcxproj +++ b/cw 9/grk-cw9.vcxproj @@ -128,7 +128,7 @@ true true true - opengl32.lib;freeglut.lib;glew32.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3dll.lib;zlibd.lib;assimp-vc141-mtd.lib;%(AdditionalDependencies) + opengl32.lib;freeglut.lib;glew32.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3dll.lib;zlibd.lib;assimp-vc141-mtd.lib;Winmm.lib;%(AdditionalDependencies) $(SolutionDir)dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019;%(AdditionalLibraryDirectories) diff --git a/cw 9/models/untitled.obj b/cw 9/models/untitled.obj new file mode 100644 index 0000000..a6f72a6 --- /dev/null +++ b/cw 9/models/untitled.obj @@ -0,0 +1,15 @@ +# Blender 3.4.1 +# www.blender.org +mtllib untitled.mtl +o Plane +v 1.017000 -0.245879 0.050232 +v -0.982771 -0.245879 0.020024 +v 1.016943 1.754118 0.054007 +v -0.982828 1.754118 0.023799 +vn 0.0151 0.0019 -0.9999 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +s 0 +f 1/1/1 2/2/1 4/4/1 3/3/1 diff --git a/cw 9/shaders/shader_9_1.frag b/cw 9/shaders/shader_9_1.frag index 69bea75..d44f821 100644 --- a/cw 9/shaders/shader_9_1.frag +++ b/cw 9/shaders/shader_9_1.frag @@ -103,13 +103,11 @@ float calculateShadow() { vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5; - float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).r; + float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).x; - if(closestDepth + 0.01 > sunSpacePosNormalized.z){ - return 1.0; - } else { - return 0.0; - } + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; } diff --git a/cw 9/shaders/shader_tex.frag b/cw 9/shaders/shader_tex.frag index 5776d07..0fe13d3 100644 --- a/cw 9/shaders/shader_tex.frag +++ b/cw 9/shaders/shader_tex.frag @@ -38,6 +38,8 @@ in vec3 lightDirTS; in vec3 spotlightDirTS; in vec3 sunDirTS; +in vec4 sunSpacePos; + vec3 color; @@ -101,6 +103,17 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){ return (kD * color / PI + specular) * radiance * NdotL; } +float calculateShadow() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5; + + float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} + void main() { @@ -132,7 +145,8 @@ void main() ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //sun - ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); + //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); + ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); diff --git a/cw 9/shaders/shader_tex.vert b/cw 9/shaders/shader_tex.vert index c5b88fc..05f1647 100644 --- a/cw 9/shaders/shader_tex.vert +++ b/cw 9/shaders/shader_tex.vert @@ -8,6 +8,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; +uniform mat4 LightVP; out vec3 vecNormal; out vec3 worldPos; @@ -22,6 +23,7 @@ out vec3 lightDirTS; out vec3 spotlightDirTS; out vec3 sunDirTS; out vec2 vecTex; +out vec4 sunSpacePos; void main() { @@ -43,5 +45,6 @@ void main() vec3 SL = normalize(spotlightPos-worldPos); spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; + sunSpacePos=LightVP*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 27fad9a..8c015f6 100644 --- a/cw 9/shaders/shader_tex_pbr.frag +++ b/cw 9/shaders/shader_tex_pbr.frag @@ -3,14 +3,16 @@ float AMBIENT = 0.03; float PI = 3.14; -uniform sampler2D depthMap; + uniform vec3 cameraPos; +uniform sampler2D depthMap; uniform sampler2D colorTexture; uniform sampler2D metallicTexture; uniform sampler2D roughnessTexture; uniform sampler2D aoTexture; +uniform sampler2D normalSampler; uniform vec3 sunDir; uniform vec3 sunColor; @@ -43,6 +45,8 @@ vec3 color; float metallic; float roughness; +in vec4 sunSpacePos; + float DistributionGGX(vec3 normal, vec3 H, float roughness){ float a = roughness*roughness; @@ -104,6 +108,17 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){ return (kD * color / PI + specular) * radiance * NdotL; } +float calculateShadow() { + + vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5; + + float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).x; + + float diff = (0.001+closestDepth) - sunSpacePosNormalized.z; + + return (0.5*(diff)/abs(diff))+0.5; +} + void main() { @@ -113,6 +128,8 @@ void main() //vec3 normal = vec3(0,0,1); vec3 normal = normalize(vecNormal); + //vec3 normal = texture(normalSampler, vecTex).rgb; + //normal = normalize(normal * 2.0 - 1.0); //vec3 viewDir = normalize(viewDirTS); vec3 viewDir = normalize(cameraPos-worldPos); @@ -121,11 +138,12 @@ void main() vec3 lightDir = normalize(lightPos-worldPos); - vec3 ambient = texture(aoTexture, vecTex).xyz*color; vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2); vec3 ilumination; ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir); + + //flashlight //vec3 spotlightDir= normalize(spotlightDirTS); @@ -137,9 +155,8 @@ void main() ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //sun - ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); - + //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); + ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); - outColor = vec4(texture(colorTexture, vecTex).rgb,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 d8c3988..821e75d 100644 --- a/cw 9/shaders/shader_tex_pbr.vert +++ b/cw 9/shaders/shader_tex_pbr.vert @@ -8,6 +8,7 @@ layout(location = 4) in vec3 vertexBitangent; uniform mat4 transformation; uniform mat4 modelMatrix; +uniform mat4 LightVP; out vec3 vecNormal; out vec3 worldPos; @@ -16,25 +17,21 @@ uniform vec3 lightPos; uniform vec3 spotlightPos; uniform vec3 cameraPos; uniform vec3 sunDir; -uniform sampler2D normalSampler; out vec3 viewDirTS; out vec3 lightDirTS; out vec3 spotlightDirTS; out vec3 sunDirTS; out vec2 vecTex; - -vec3 normal; +out vec4 sunSpacePos; void main() { - normal = texture(normalSampler, vecTex).rgb; - normal = normalize(normal * 2.0 - 1.0); vecTex = vertexTexCoord; vecTex.y = 1.0 - vecTex.y; worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz; - vecNormal = (modelMatrix* vec4(normal,0)).xyz; + vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz; gl_Position = transformation * vec4(vertexPosition, 1.0); vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent); @@ -48,5 +45,66 @@ void main() vec3 SL = normalize(spotlightPos-worldPos); spotlightDirTS = TBN*SL; sunDirTS = TBN*sunDir; + sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); -} \ No newline at end of file +} + +/* +#version 430 core + +layout(location = 0) in vec3 vertexPosition; +layout(location = 1) in vec3 vertexNormal; +layout(location = 2) in vec2 vertexTexCoord; +layout(location = 3) in vec3 vertexTangent; +layout(location = 4) in vec3 vertexBitangent; + +uniform mat4 transformation; +uniform mat4 modelMatrix; +uniform mat4 LightVP; +uniform sampler2D normalSampler; + +out vec3 vecNormal; +out vec3 worldPos; + +uniform vec3 lightPos; +uniform vec3 spotlightPos; +uniform vec3 cameraPos; +uniform vec3 sunDir; + +out vec3 viewDirTS; +out vec3 lightDirTS; +out vec3 spotlightDirTS; +out vec3 sunDirTS; +out vec2 vecTex; +out vec4 sunSpacePos; + +vec3 normal; + +void main() +{ + vecTex = vertexTexCoord; + vecTex.y = 1.0 - vecTex.y; + + normal = texture(normalSampler, vecTex).xyz; + normal = normalize(normal * 2.0 - 1.0); + + worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz; + vecNormal = (modelMatrix* vec4(normal,0)).xyz; + //vecNormal = normalize(vecNormal); + gl_Position = transformation * vec4(vertexPosition, 1.0); + + vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent); + vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent); + mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal)); + + vec3 V = normalize(cameraPos-worldPos); + viewDirTS = TBN*V; + vec3 L = normalize(lightPos-worldPos); + lightDirTS = TBN*L; + vec3 SL = normalize(spotlightPos-worldPos); + spotlightDirTS = TBN*SL; + sunDirTS = TBN*sunDir; + sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); + +} +*/ \ No newline at end of file diff --git a/cw 9/shaders/shader_water.frag b/cw 9/shaders/shader_water.frag index 6b6f376..762a74b 100644 --- a/cw 9/shaders/shader_water.frag +++ b/cw 9/shaders/shader_water.frag @@ -1,4 +1,4 @@ -#version 330 core +#version 430 core in vec3 pos; in vec3 interpolatedNormal; diff --git a/cw 9/shaders/shader_water.vert b/cw 9/shaders/shader_water.vert index 80eeddb..4401013 100644 --- a/cw 9/shaders/shader_water.vert +++ b/cw 9/shaders/shader_water.vert @@ -1,4 +1,4 @@ -#version 330 core +#version 430 core layout(location = 0) in vec3 Position; layout ( location =1) in vec3 Normal; diff --git a/cw 9/sound/grass.wav b/cw 9/sound/grass.wav new file mode 100644 index 0000000..ce88769 Binary files /dev/null and b/cw 9/sound/grass.wav differ diff --git a/cw 9/sound/main.wav b/cw 9/sound/main.wav new file mode 100644 index 0000000..559f006 Binary files /dev/null and b/cw 9/sound/main.wav differ diff --git a/cw 9/sound/necro.wav b/cw 9/sound/necro.wav new file mode 100644 index 0000000..f38768b Binary files /dev/null and b/cw 9/sound/necro.wav differ diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index 93a42df..68a36db 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -21,6 +21,7 @@ const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; int WIDTH = 500, HEIGHT = 500; + namespace models { Core::RenderContext bedContext; Core::RenderContext chairContext; @@ -38,6 +39,7 @@ namespace models { Core::RenderContext testContext; Core::RenderContext cubeContext; Core::RenderContext tableContext; + Core::RenderContext planeSmallContex; } std::vector faces = { @@ -57,6 +59,22 @@ namespace texture { GLuint table_ao; GLuint table_normal; GLuint table_roughness; + GLuint wood_albedo; + GLuint wood_metallic; + GLuint wood_ao; + GLuint wood_normal; + GLuint wood_roughness; + GLuint metal_albedo; + GLuint metal_metallic; + GLuint metal_ao; + GLuint metal_normal; + GLuint metal_roughness; + GLuint panels_albedo; + GLuint panels_metallic; + GLuint panels_ao; + GLuint panels_normal; + GLuint panels_roughness; + GLuint screen; } GLuint depthMapFBO; @@ -171,8 +189,8 @@ glm::mat4 createPerspectiveMatrix() glm::mat4 perspectiveMatrix; float n = 0.05; float f = 20.; - float a1 = glm::min(aspectRatio, 1.f); - float a2 = glm::min(1 / aspectRatio, 1.f); + float a1 = min(aspectRatio, 1.f); + float a2 = min(1 / aspectRatio, 1.f); perspectiveMatrix = glm::mat4({ 1,0.,0.,0., 0.,aspectRatio,0.,0., @@ -248,11 +266,11 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro glUniform1f(glGetUniformLocation(programTex, "spotlightPhi"), spotlightPhi); Core::SetActiveTexture(texture, "colorTexture", programTex, 0); - Core::DrawContext(context); + //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(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP); - Core::SetActiveTexture(depthMap, "depthMap", program, 0); + glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP"), 1, GL_FALSE, (float*)&lightVP); + Core::SetActiveTexture(depthMap, "depthMap", programTex, 1); Core::DrawContext(context); } @@ -283,17 +301,17 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin glUniform3f(glGetUniformLocation(programTexPBR, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z); glUniform3f(glGetUniformLocation(programTexPBR, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z); glUniform1f(glGetUniformLocation(programTexPBR, "spotlightPhi"), spotlightPhi); - Core::SetActiveTexture(texture, "colorTexture", programTexPBR, 0); - Core::SetActiveTexture(metallic, "metallicTexture", programTexPBR, 1); - Core::SetActiveTexture(roughness, "roughnessTexture", programTexPBR, 2); - Core::SetActiveTexture(ao, "aoTexture", programTexPBR, 3); - Core::SetActiveTexture(normal, "normalSampler", programTexPBR,4); + Core::SetActiveTexture(texture, "colorTexture", programTexPBR, 1); + Core::SetActiveTexture(metallic, "metallicTexture", programTexPBR, 2); + Core::SetActiveTexture(roughness, "roughnessTexture", programTexPBR, 3); + Core::SetActiveTexture(ao, "aoTexture", programTexPBR, 4); + Core::SetActiveTexture(normal, "normalSampler", programTexPBR,5); - Core::DrawContext(context); + //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(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP); - Core::SetActiveTexture(depthMap, "depthMap", program, 0); + glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP"), 1, GL_FALSE, (float*)&lightVP); + Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0); Core::DrawContext(context); } @@ -411,7 +429,7 @@ void renderScene(GLFWwindow* window) 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::materaceContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f); @@ -448,9 +466,12 @@ void renderScene(GLFWwindow* window) glUseProgram(programTex); 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::planeSmallContex, glm::translate(glm::mat4(), glm::vec3(0, 0, 2)), 0, 0, texture::screen); + //drawObjectTex(models::deskContext, glm::mat4(), 0.2f, 0.0f, texture::rust); glUseProgram(programTexPBR); drawObjectTexPBR(models::tableContext, glm::mat4(), texture::table_roughness, texture::table_metallic, texture::table_albedo, texture::table_normal, texture::table_ao); + drawObjectTexPBR(models::deskContext, glm::mat4(), texture::panels_roughness, texture::panels_metallic, texture::panels_albedo, texture::panels_normal, texture::panels_ao); 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); @@ -515,6 +536,22 @@ void init(GLFWwindow* window) texture::table_roughness = Core::LoadTexture("textures/table_roughness.png"); texture::table_ao = Core::LoadTexture("textures/table_ao.png"); texture::table_normal = Core::LoadTexture("textures/table_normal.png"); + texture::wood_albedo = Core::LoadTexture("textures/wood_albedo.jpg"); + texture::wood_metallic = Core::LoadTexture("textures/wood_metallic.jpg"); + texture::wood_roughness = Core::LoadTexture("textures/wood_roughness.jpg"); + texture::wood_ao = Core::LoadTexture("textures/wood_ao.jpg"); + texture::wood_normal = Core::LoadTexture("textures/wood_normal.jpg"); + texture::screen = Core::LoadTexture("textures/visual.png"); + texture::metal_albedo = Core::LoadTexture("textures/metal_albedo.png"); + texture::metal_metallic = Core::LoadTexture("textures/metal_metallic.png"); + texture::metal_roughness = Core::LoadTexture("textures/metal_roughness.png"); + texture::metal_ao = Core::LoadTexture("textures/metal_ao.png"); + texture::metal_normal = Core::LoadTexture("textures/metal_normal.png"); + texture::panels_albedo = Core::LoadTexture("textures/panels_albedo.png"); + texture::panels_metallic = Core::LoadTexture("textures/panels_metallic.png"); + texture::panels_roughness = Core::LoadTexture("textures/panels_roughness.png"); + texture::panels_ao = Core::LoadTexture("textures/panels_ao.png"); + texture::panels_normal = Core::LoadTexture("textures/panels_normal.png"); loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/spaceship.obj", shipContext); loadModelToContext("./models/bed.obj", models::bedContext); @@ -533,7 +570,8 @@ void init(GLFWwindow* window) loadModelToContext("./models/test.obj", models::testContext); loadModelToContext("./models/cube.obj", models::cubeContext); loadModelToContext("./models/table.obj", models::tableContext); - + loadModelToContext("./models/untitled.obj", models::planeSmallContex); + skyboxTexture = loadSkybox(faces); drawSkybox(models::cubeContext, transformation, skyboxTexture); /*glUseProgram(programSkybox); @@ -549,6 +587,7 @@ void shutdown(GLFWwindow* window) shaderLoader.DeleteProgram(program); } + //obsluga wejscia void processInput(GLFWwindow* window) { @@ -575,6 +614,15 @@ void processInput(GLFWwindow* window) spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0)); if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0)); + if (glfwGetKey(window, GLFW_KEY_H) == GLFW_PRESS) { + texture::screen = Core::LoadTexture("textures/heroes.jpg"); + PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC); + } + if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) { + texture::screen = Core::LoadTexture("textures/visual.png"); + PlaySound(nullptr, nullptr, 0); + } + cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f; cameraDir = spaceshipDir; diff --git a/cw 9/src/main.cpp b/cw 9/src/main.cpp index 4e939cd..7a76339 100644 --- a/cw 9/src/main.cpp +++ b/cw 9/src/main.cpp @@ -5,7 +5,7 @@ #include "ext.hpp" #include #include - +#include #include "ex_9_1.hpp" diff --git a/cw 9/textures/heroes.jpg b/cw 9/textures/heroes.jpg new file mode 100644 index 0000000..926f6f3 Binary files /dev/null and b/cw 9/textures/heroes.jpg differ diff --git a/cw 9/textures/metal_albedo.png b/cw 9/textures/metal_albedo.png new file mode 100644 index 0000000..8d70678 Binary files /dev/null and b/cw 9/textures/metal_albedo.png differ diff --git a/cw 9/textures/metal_ao.png b/cw 9/textures/metal_ao.png new file mode 100644 index 0000000..f415ed9 Binary files /dev/null and b/cw 9/textures/metal_ao.png differ diff --git a/cw 9/textures/metal_metallic.png b/cw 9/textures/metal_metallic.png new file mode 100644 index 0000000..f6f8e57 Binary files /dev/null and b/cw 9/textures/metal_metallic.png differ diff --git a/cw 9/textures/metal_normal.png b/cw 9/textures/metal_normal.png new file mode 100644 index 0000000..a89326e Binary files /dev/null and b/cw 9/textures/metal_normal.png differ diff --git a/cw 9/textures/metal_roughness.png b/cw 9/textures/metal_roughness.png new file mode 100644 index 0000000..1f4fc60 Binary files /dev/null and b/cw 9/textures/metal_roughness.png differ diff --git a/cw 9/textures/panels_albedo.png b/cw 9/textures/panels_albedo.png new file mode 100644 index 0000000..e95027e Binary files /dev/null and b/cw 9/textures/panels_albedo.png differ diff --git a/cw 9/textures/panels_ao.png b/cw 9/textures/panels_ao.png new file mode 100644 index 0000000..9192488 Binary files /dev/null and b/cw 9/textures/panels_ao.png differ diff --git a/cw 9/textures/panels_metallic.png b/cw 9/textures/panels_metallic.png new file mode 100644 index 0000000..a7be5c9 Binary files /dev/null and b/cw 9/textures/panels_metallic.png differ diff --git a/cw 9/textures/panels_normal.png b/cw 9/textures/panels_normal.png new file mode 100644 index 0000000..d696a36 Binary files /dev/null and b/cw 9/textures/panels_normal.png differ diff --git a/cw 9/textures/panels_roughness.png b/cw 9/textures/panels_roughness.png new file mode 100644 index 0000000..346f801 Binary files /dev/null and b/cw 9/textures/panels_roughness.png differ diff --git a/cw 9/textures/visual.png b/cw 9/textures/visual.png new file mode 100644 index 0000000..42be87b Binary files /dev/null and b/cw 9/textures/visual.png differ diff --git a/cw 9/textures/wood_albedo.jpg b/cw 9/textures/wood_albedo.jpg new file mode 100644 index 0000000..26aa45b Binary files /dev/null and b/cw 9/textures/wood_albedo.jpg differ diff --git a/cw 9/textures/wood_ao.jpg b/cw 9/textures/wood_ao.jpg new file mode 100644 index 0000000..f8af6f2 Binary files /dev/null and b/cw 9/textures/wood_ao.jpg differ diff --git a/cw 9/textures/wood_metallic.jpg b/cw 9/textures/wood_metallic.jpg new file mode 100644 index 0000000..9b9f00c Binary files /dev/null and b/cw 9/textures/wood_metallic.jpg differ diff --git a/cw 9/textures/wood_normal.jpg b/cw 9/textures/wood_normal.jpg new file mode 100644 index 0000000..7d705bb Binary files /dev/null and b/cw 9/textures/wood_normal.jpg differ diff --git a/cw 9/textures/wood_roughness.jpg b/cw 9/textures/wood_roughness.jpg new file mode 100644 index 0000000..450b112 Binary files /dev/null and b/cw 9/textures/wood_roughness.jpg differ