diff --git a/grk/cw 6/Debug/Box.obj b/grk/cw 6/Debug/Box.obj index f3f7c75..fa8f834 100644 Binary files a/grk/cw 6/Debug/Box.obj and b/grk/cw 6/Debug/Box.obj differ diff --git a/grk/cw 6/Debug/Camera.obj b/grk/cw 6/Debug/Camera.obj index 66bd87a..186c80f 100644 Binary files a/grk/cw 6/Debug/Camera.obj and b/grk/cw 6/Debug/Camera.obj differ diff --git a/grk/cw 6/Debug/Render_Utils.obj b/grk/cw 6/Debug/Render_Utils.obj index 5fdf5b0..76359a2 100644 Binary files a/grk/cw 6/Debug/Render_Utils.obj and b/grk/cw 6/Debug/Render_Utils.obj differ diff --git a/grk/cw 6/Debug/SOIL.obj b/grk/cw 6/Debug/SOIL.obj index 2c349d4..a6e0350 100644 Binary files a/grk/cw 6/Debug/SOIL.obj and b/grk/cw 6/Debug/SOIL.obj differ diff --git a/grk/cw 6/Debug/Shader_Loader.obj b/grk/cw 6/Debug/Shader_Loader.obj index e0a87ee..03d7fd2 100644 Binary files a/grk/cw 6/Debug/Shader_Loader.obj and b/grk/cw 6/Debug/Shader_Loader.obj differ diff --git a/grk/cw 6/Debug/Texture.obj b/grk/cw 6/Debug/Texture.obj index 6803a0f..f41f455 100644 Binary files a/grk/cw 6/Debug/Texture.obj and b/grk/cw 6/Debug/Texture.obj differ diff --git a/grk/cw 6/Debug/grk-cw6.Build.CppClean.log b/grk/cw 6/Debug/grk-cw6.Build.CppClean.log index 0df61fb..22b63b3 100644 --- a/grk/cw 6/Debug/grk-cw6.Build.CppClean.log +++ b/grk/cw 6/Debug/grk-cw6.Build.CppClean.log @@ -1,23 +1,10 @@ -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.pdb -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.idb -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\texture.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\shader_loader.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\render_utils.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\main.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\camera.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\box.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\stb_image_aug.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\soil.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\image_helper.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\image_dxt.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vcpkg.applocal.log -c:\users\andrzej\desktop\grk\2021\grk glfw test\debug\grk-cw6.exe -c:\users\andrzej\desktop\grk\2021\grk glfw test\debug\grk-cw6.pdb -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\main_3_1.obj -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.command.1.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.read.1.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.write.1.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\grk-cw6.write.1u.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.command.1.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.read.1.tlog -c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.write.1.tlog +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.pdb +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.idb +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\texture.obj +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\shader_loader.obj +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\render_utils.obj +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\camera.obj +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\box.obj +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.read.1.tlog +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.write.1.tlog +e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.command.1.tlog diff --git a/grk/cw 6/Debug/grk-cw6.exe.recipe b/grk/cw 6/Debug/grk-cw6.exe.recipe index 3b7366c..d9077bc 100644 --- a/grk/cw 6/Debug/grk-cw6.exe.recipe +++ b/grk/cw 6/Debug/grk-cw6.exe.recipe @@ -2,7 +2,7 @@ - j:\Downloads\grk\Debug\grk-cw6.exe + E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe diff --git a/grk/cw 6/Debug/grk-cw6.log b/grk/cw 6/Debug/grk-cw6.log index e312cc0..989ad23 100644 --- a/grk/cw 6/Debug/grk-cw6.log +++ b/grk/cw 6/Debug/grk-cw6.log @@ -1,39 +1,39 @@ -C:\software\vs19\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(513,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj). This can lead to incorrect clean and rebuild behavior. +C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(513,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj). This can lead to incorrect clean and rebuild behavior. main.cpp C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition -j:\Downloads\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(92,16): warning C4305: 'initializing': truncation from 'double' to 'float' -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(135,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(139,52): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(96,16): warning C4305: 'initializing': truncation from 'double' to 'float' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(152,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(156,52): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(143,50): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(160,50): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(147,49): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(164,49): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(151,48): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(168,48): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(155,48): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(172,48): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -j:\Downloads\grk\cw 6\src\ex_6_1.hpp(159,48): warning C4305: 'argument': truncation from 'double' to 'T' +E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(176,48): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library - grk-cw6.vcxproj -> j:\Downloads\grk\Debug\grk-cw6.exe + grk-cw6.vcxproj -> E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe diff --git a/grk/cw 6/Debug/grk-cw6.tlog/CL.command.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/CL.command.1.tlog index 6088b04..d0e4c7d 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/CL.command.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/CL.command.1.tlog differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/CL.read.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/CL.read.1.tlog index 6859103..83011d4 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/CL.read.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/CL.read.1.tlog differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/CL.write.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/CL.write.1.tlog index c626fad..059b330 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/CL.write.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/CL.write.1.tlog differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.lastbuildstate b/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.lastbuildstate index 8b180b4..1134c0c 100644 --- a/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.lastbuildstate +++ b/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: -Debug|Win32|j:\Downloads\grk\| +Debug|Win32|E:\micha\studia\grafika_komputerowa\grk\grk\| diff --git a/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.write.1u.tlog b/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.write.1u.tlog deleted file mode 100644 index 70896e5..0000000 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.write.1u.tlog and /dev/null differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/link.command.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/link.command.1.tlog index 5874b07..ce24eeb 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/link.command.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/link.command.1.tlog differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/link.read.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/link.read.1.tlog index 54e81ce..9e27c7f 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/link.read.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/link.read.1.tlog differ diff --git a/grk/cw 6/Debug/grk-cw6.tlog/link.write.1.tlog b/grk/cw 6/Debug/grk-cw6.tlog/link.write.1.tlog index 9cbc2aa..1342dc2 100644 Binary files a/grk/cw 6/Debug/grk-cw6.tlog/link.write.1.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/link.write.1.tlog differ diff --git a/grk/cw 6/Debug/image_DXT.obj b/grk/cw 6/Debug/image_DXT.obj index 6487825..e311c2c 100644 Binary files a/grk/cw 6/Debug/image_DXT.obj and b/grk/cw 6/Debug/image_DXT.obj differ diff --git a/grk/cw 6/Debug/image_helper.obj b/grk/cw 6/Debug/image_helper.obj index 467954c..9b7f75d 100644 Binary files a/grk/cw 6/Debug/image_helper.obj and b/grk/cw 6/Debug/image_helper.obj differ diff --git a/grk/cw 6/Debug/main.obj b/grk/cw 6/Debug/main.obj index 6f0f2cf..1e9f2c0 100644 Binary files a/grk/cw 6/Debug/main.obj and b/grk/cw 6/Debug/main.obj differ diff --git a/grk/cw 6/Debug/stb_image_aug.obj b/grk/cw 6/Debug/stb_image_aug.obj index 772e88f..acaf221 100644 Binary files a/grk/cw 6/Debug/stb_image_aug.obj and b/grk/cw 6/Debug/stb_image_aug.obj differ diff --git a/grk/cw 6/Debug/vc142.idb b/grk/cw 6/Debug/vc142.idb index 2cccf02..2b99e8e 100644 Binary files a/grk/cw 6/Debug/vc142.idb and b/grk/cw 6/Debug/vc142.idb differ diff --git a/grk/cw 6/Debug/vc142.pdb b/grk/cw 6/Debug/vc142.pdb index 94b5c65..d388414 100644 Binary files a/grk/cw 6/Debug/vc142.pdb and b/grk/cw 6/Debug/vc142.pdb differ diff --git a/grk/cw 6/shaders/shader_5_1_tex.frag b/grk/cw 6/shaders/shader_5_1_tex.frag index 99d90fd..deb0bdc 100644 --- a/grk/cw 6/shaders/shader_5_1_tex.frag +++ b/grk/cw 6/shaders/shader_5_1_tex.frag @@ -7,18 +7,18 @@ uniform vec3 lightPos; in vec3 vecNormal; in vec3 worldPos; +in vec2 vtc; out vec4 outColor; -in vec2 vTC; uniform sampler2D colorTexture; void main() { - vec3 lightDir = normalize(lightPos-worldPos); + vec3 lightDir = normalize(lightPos - worldPos); vec3 normal = normalize(vecNormal); - float diffuse=max(0,dot(normal,lightDir)); + float diffuse = max(0, dot(normal, lightDir)); - vec4 textureColor = texture2D(colorTexture, vTC); - outColor = vec4(vec3(textureColor)*min(1,AMBIENT+diffuse), 1.0); + vec4 textureColor = texture2D(colorTexture, vtc); + outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0); } diff --git a/grk/cw 6/shaders/shader_5_1_tex.vert b/grk/cw 6/shaders/shader_5_1_tex.vert index 5c2ea01..0e0d4c8 100644 --- a/grk/cw 6/shaders/shader_5_1_tex.vert +++ b/grk/cw 6/shaders/shader_5_1_tex.vert @@ -10,7 +10,7 @@ uniform mat4 modelMatrix; out vec3 vecNormal; out vec3 worldPos; -out vec2 vTC; +out vec2 vtc; void main() { @@ -18,5 +18,5 @@ void main() vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz; gl_Position = transformation * vec4(vertexPosition, 1.0); - vTC = vertexTexCoord; + vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y); } diff --git a/grk/cw 6/shaders/shader_5_sun.frag b/grk/cw 6/shaders/shader_5_sun.frag index 5cf78d5..fae30ff 100644 --- a/grk/cw 6/shaders/shader_5_sun.frag +++ b/grk/cw 6/shaders/shader_5_sun.frag @@ -1,10 +1,25 @@ #version 430 core -uniform vec3 objectColor; +float AMBIENT = 0.1; -in vec3 interpNormal; +uniform vec3 color; +uniform vec3 lightPos; + + +in vec3 vecNormal; +in vec3 worldPos; +in vec2 vtc; + +out vec4 outColor; + +uniform sampler2D colorTexture; void main() { - gl_FragColor = vec4(objectColor, 1.0); + vec3 lightDir = normalize(lightPos - worldPos); + vec3 normal = normalize(vecNormal); + float diffuse = max(0, dot(normal, lightDir)); + + vec4 textureColor = texture2D(colorTexture, vtc); + outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0) * 7.0; } diff --git a/grk/cw 6/shaders/shader_5_sun.vert b/grk/cw 6/shaders/shader_5_sun.vert index 7d84d62..65b0f74 100644 --- a/grk/cw 6/shaders/shader_5_sun.vert +++ b/grk/cw 6/shaders/shader_5_sun.vert @@ -1,15 +1,22 @@ #version 430 core layout(location = 0) in vec3 vertexPosition; -layout(location = 1) in vec2 vertexTexCoord; -layout(location = 2) in vec3 vertexNormal; +layout(location = 1) in vec3 vertexNormal; +layout(location = 2) in vec2 vertexTexCoord; uniform mat4 transformation; +uniform mat4 modelMatrix; -out vec3 interpNormal; +out vec3 vecNormal; +out vec3 worldPos; +out vec2 vtc; void main() { + worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz; + vecNormal = (modelMatrix * vec4(vertexNormal, 1)).xyz; gl_Position = transformation * vec4(vertexPosition, 1.0); - interpNormal = vertexNormal; + + //vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y); + vtc = vertexTexCoord; } diff --git a/grk/cw 6/src/ex_6_1.hpp b/grk/cw 6/src/ex_6_1.hpp index 128d9c7..d8de76e 100644 --- a/grk/cw 6/src/ex_6_1.hpp +++ b/grk/cw 6/src/ex_6_1.hpp @@ -24,6 +24,7 @@ namespace texture { GLuint mercury; GLuint venus; GLuint mars; + GLuint sun; GLuint grid; @@ -116,6 +117,19 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui glm::mat4 transformation = viewProjectionMatrix * modelMatrix; glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation); glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix); + glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0); + Core::DrawContext(context); + glUseProgram(0); +} + +void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) { + glUseProgram(programSun); + glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix(); + glm::mat4 transformation = viewProjectionMatrix * modelMatrix; + glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation); + glUniformMatrix4fv(glGetUniformLocation(programSun, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix); + Core::SetActiveTexture(texture, "colorTexture", programSun, 3); + glUniform3f(glGetUniformLocation(programSun, "lightPos"), 0, 0, 0); Core::DrawContext(context); glUseProgram(0); } @@ -164,15 +178,13 @@ void renderScene(GLFWwindow* window) glm::mat4 shipTranslate = glm::translate(shipPos); - glUseProgram(program); - //glUniform3f(glGetUniformLocation(program, "lightDir"), 1.0, -1.0, 0.0); - //glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z); - //glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); - glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0); - glUseProgram(0); + //glUseProgram(program); - drawObjectColor(sphereContext, sunScale, glm::vec3(0.9, 0.9, 0.2)); //sun + //glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0); + //glUseProgram(0); + drawSun(sphereContext, sunScale, texture::sun); + drawObjectTexture(sphereContext, mercuryRotate * mercuryTranslate * mercuryScale, texture::mercury); //mercury drawObjectTexture(sphereContext, venusRotate * venusTranslate * venusScale, texture::venus); //venus @@ -212,6 +224,7 @@ void init(GLFWwindow* window) glEnable(GL_DEPTH_TEST); program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag"); programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag"); + programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag"); loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/spaceship.obj", shipContext); @@ -224,6 +237,7 @@ void init(GLFWwindow* window) texture::mercury = Core::LoadTexture("./textures/mercury.jpg"); texture::venus = Core::LoadTexture("./textures/venus.jpg"); texture::mars = Core::LoadTexture("./textures/mars.jpg"); + texture::sun = Core::LoadTexture("./textures/sun.jpg"); //texture::earthNormal = Core::LoadTexture("./textures/earth_normalmap.png"); //texture::asteroidNormal = Core::LoadTexture("./textures/moon_normals.png"); diff --git a/grk/cw 6/textures/sun.jpg b/grk/cw 6/textures/sun.jpg new file mode 100644 index 0000000..9d787d8 Binary files /dev/null and b/grk/cw 6/textures/sun.jpg differ