diff --git a/cw 9/Debug/grk-cw9.log b/cw 9/Debug/grk-cw9.log index 6a700e6..97e2aea 100644 --- a/cw 9/Debug/grk-cw9.log +++ b/cw 9/Debug/grk-cw9.log @@ -2,43 +2,43 @@ 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\Genos\Source\Repos\GRK_Room2\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(94,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(109,38): warning C4305: "=": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(132,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(153,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(172,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(252,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(263,96): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(97,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(112,38): warning C4305: "=": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(135,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(156,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(175,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(258,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(269,96): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(267,59): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(273,59): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(343,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(353,108): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(349,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(359,108): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(361,87): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(367,87): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(361,223): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(364,59): warning C4305: "argument": obcięcie z "double" do "T" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(367,223): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(370,59): warning C4305: "argument": obcięcie z "double" do "T" with [ T=float ] -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(365,37): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(393,2): warning C4305: "argument": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(501,21): warning C4305: "-=": obcięcie z "double" do "float" -C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(503,21): warning C4305: "+=": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(371,37): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(399,2): warning C4305: "argument": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(510,21): warning C4305: "-=": obcięcie z "double" do "float" +C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(512,21): warning C4305: "+=": obcięcie z "double" do "float" Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO” LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka grk-cw9.vcxproj -> C:\Users\Genos\Source\Repos\GRK_Room2\Debug\room.exe diff --git a/cw 9/Debug/main.obj b/cw 9/Debug/main.obj index 2585347..b54bed8 100644 Binary files a/cw 9/Debug/main.obj and b/cw 9/Debug/main.obj differ diff --git a/cw 9/Debug/room.tlog/CL.read.1.tlog b/cw 9/Debug/room.tlog/CL.read.1.tlog index 3835268..4a05e39 100644 Binary files a/cw 9/Debug/room.tlog/CL.read.1.tlog and b/cw 9/Debug/room.tlog/CL.read.1.tlog differ diff --git a/cw 9/Debug/vc142.idb b/cw 9/Debug/vc142.idb index 589394e..076cf30 100644 Binary files a/cw 9/Debug/vc142.idb and b/cw 9/Debug/vc142.idb differ diff --git a/cw 9/Debug/vc142.pdb b/cw 9/Debug/vc142.pdb index be0eff8..fc2bb01 100644 Binary files a/cw 9/Debug/vc142.pdb and b/cw 9/Debug/vc142.pdb differ diff --git a/cw 9/shaders/shader_9_1.frag b/cw 9/shaders/shader_9_1.frag index abf864b..64500bf 100644 --- a/cw 9/shaders/shader_9_1.frag +++ b/cw 9/shaders/shader_9_1.frag @@ -6,9 +6,12 @@ float PI = 3.14; uniform sampler2D depthMap; uniform sampler2D depthMapShip; +uniform sampler2D colorTexture; +uniform sampler2D normalSampler; + uniform vec3 cameraPos; -uniform vec3 color; +vec3 color; uniform vec3 sunDir; uniform vec3 sunColor; @@ -42,6 +45,8 @@ in vec3 test; in vec4 sunSpacePos; in vec4 shipPos; +in vec2 vecTex; + float calculateShadow(vec3 normal, vec3 light, vec4 pos, sampler2D depth) { vec4 posNormalized = (pos / pos.w) * 0.5 + 0.5; float closestDepth = texture2D(depth, posNormalized.xy).r; @@ -117,13 +122,16 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){ void main() { //vec3 normal = vec3(0,0,1); - vec3 normal = normalize(vecNormal); + //vec3 normal = normalize(vecNormal); - //vec3 viewDir = normalize(viewDirTS); - vec3 viewDir = normalize(cameraPos-worldPos); + color = texture2D(colorTexture, vecTex).xyz; + vec3 normal = normalize((texture2D(normalSampler, vecTex).xyz) * 2 - 1); - //vec3 lightDir = normalize(lightDirTS); - vec3 lightDir = normalize(lightPos-worldPos); + vec3 viewDir = normalize(viewDirTS); + //vec3 viewDir = normalize(cameraPos-worldPos); + + vec3 lightDir = normalize(lightDirTS); + //vec3 lightDir = normalize(lightPos-worldPos); vec3 ambient = AMBIENT*color; @@ -132,8 +140,8 @@ void main() ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir); //flashlight - //vec3 spotlightDir= normalize(spotlightDirTS); - vec3 spotlightDir= normalize(spotlightPos-worldPos); + vec3 spotlightDir= normalize(spotlightDirTS); + //vec3 spotlightDir= normalize(spotlightPos-worldPos); float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); diff --git a/cw 9/shaders/shader_9_1.vert b/cw 9/shaders/shader_9_1.vert index ffac9c6..99af65b 100644 --- a/cw 9/shaders/shader_9_1.vert +++ b/cw 9/shaders/shader_9_1.vert @@ -26,6 +26,7 @@ out vec3 sunDirTS; out vec4 sunSpacePos; out vec4 shipPos; +out vec2 vecTex; void main() { @@ -39,6 +40,8 @@ void main() vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent); vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent); mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal)); + + vecTex = vertexTexCoord; vec3 V = normalize(cameraPos-worldPos); viewDirTS = TBN*V; diff --git a/cw 9/src/room.hpp b/cw 9/src/room.hpp index af4ec01..7536c1a 100644 --- a/cw 9/src/room.hpp +++ b/cw 9/src/room.hpp @@ -7,7 +7,7 @@ #include "Shader_Loader.h" #include "Render_Utils.h" -//#include "Texture.h" +#include "Texture.h" #include "Box.cpp" #include @@ -38,6 +38,9 @@ namespace models { namespace texture { GLuint cubemapTexture; + + GLuint earth; + GLuint earthNormal; } Core::RenderContext cubeContext;; @@ -232,7 +235,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glUniform1f(glGetUniformLocation(program, "roughness"), roughness); glUniform1f(glGetUniformLocation(program, "metallic"), metallic); - glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z); + //glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z); glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); @@ -246,6 +249,9 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z); glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z); glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi); + + Core::SetActiveTexture(texture::earth, "colorTexture", program, 2); + Core::SetActiveTexture(texture::earthNormal, "normalSampler", program, 3); Core::DrawContext(context); } void renderShadowapSun(GLuint depthFBO, glm::mat4 light) { @@ -441,6 +447,9 @@ void init(GLFWwindow* window) loadCubemap(faces); initDepthMap(); + texture::earth = Core::LoadTexture("textures/room/earth.png"); + texture::earthNormal = Core::LoadTexture("textures/room/earth_normalmap.png"); + loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/spaceship.obj", shipContext); loadModelToContext("./models/cube.obj", cubeContext); diff --git a/cw 9/textures/room/Concrete_Wall_009_ambientOcclusion.jpg b/cw 9/textures/room/Concrete_Wall_009_ambientOcclusion.jpg deleted file mode 100644 index 3d2c313..0000000 Binary files a/cw 9/textures/room/Concrete_Wall_009_ambientOcclusion.jpg and /dev/null differ diff --git a/cw 9/textures/room/Concrete_Wall_009_basecolor.jpg b/cw 9/textures/room/Concrete_Wall_009_basecolor.jpg deleted file mode 100644 index a01e092..0000000 Binary files a/cw 9/textures/room/Concrete_Wall_009_basecolor.jpg and /dev/null differ diff --git a/cw 9/textures/room/Concrete_Wall_009_height.png b/cw 9/textures/room/Concrete_Wall_009_height.png deleted file mode 100644 index 283b2cf..0000000 Binary files a/cw 9/textures/room/Concrete_Wall_009_height.png and /dev/null differ diff --git a/cw 9/textures/room/Concrete_Wall_009_normal.jpg b/cw 9/textures/room/Concrete_Wall_009_normal.jpg deleted file mode 100644 index d21d03c..0000000 Binary files a/cw 9/textures/room/Concrete_Wall_009_normal.jpg and /dev/null differ diff --git a/cw 9/textures/room/earth.png b/cw 9/textures/room/earth.png new file mode 100644 index 0000000..2aed90c Binary files /dev/null and b/cw 9/textures/room/earth.png differ diff --git a/cw 9/textures/room/earth2.jpg b/cw 9/textures/room/earth2.jpg new file mode 100644 index 0000000..c1bed86 Binary files /dev/null and b/cw 9/textures/room/earth2.jpg differ diff --git a/cw 9/textures/room/earth_normalmap.png b/cw 9/textures/room/earth_normalmap.png new file mode 100644 index 0000000..6437240 Binary files /dev/null and b/cw 9/textures/room/earth_normalmap.png differ diff --git a/cw 9/textures/room/earth_normalmap2.jpg b/cw 9/textures/room/earth_normalmap2.jpg new file mode 100644 index 0000000..8812904 Binary files /dev/null and b/cw 9/textures/room/earth_normalmap2.jpg differ diff --git a/cw 9/textures/room/wall_roughness.jpg b/cw 9/textures/room/wall_roughness.jpg deleted file mode 100644 index f67ede4..0000000 Binary files a/cw 9/textures/room/wall_roughness.jpg and /dev/null differ