diff --git a/grk/.vs/grk-cw/v16/.suo b/grk/.vs/grk-cw/v16/.suo
new file mode 100644
index 0000000..99c2422
Binary files /dev/null and b/grk/.vs/grk-cw/v16/.suo differ
diff --git a/grk/.vs/grk-cw/v16/Browse.VC.db b/grk/.vs/grk-cw/v16/Browse.VC.db
new file mode 100644
index 0000000..88ca974
Binary files /dev/null and b/grk/.vs/grk-cw/v16/Browse.VC.db differ
diff --git a/grk/.vs/grk-cw/v16/ipch/AutoPCH/520a626c2b6c2b48/MAIN.ipch b/grk/.vs/grk-cw/v16/ipch/AutoPCH/520a626c2b6c2b48/MAIN.ipch
new file mode 100644
index 0000000..019a81d
Binary files /dev/null and b/grk/.vs/grk-cw/v16/ipch/AutoPCH/520a626c2b6c2b48/MAIN.ipch differ
diff --git a/grk/.vs/grk-cw/v16/ipch/AutoPCH/824b4bc7a8383263/STB_IMAGE_AUG.ipch b/grk/.vs/grk-cw/v16/ipch/AutoPCH/824b4bc7a8383263/STB_IMAGE_AUG.ipch
new file mode 100644
index 0000000..59d0816
Binary files /dev/null and b/grk/.vs/grk-cw/v16/ipch/AutoPCH/824b4bc7a8383263/STB_IMAGE_AUG.ipch differ
diff --git a/grk/Debug/grk-cw6.exe b/grk/Debug/grk-cw6.exe
new file mode 100644
index 0000000..fdacd83
Binary files /dev/null and b/grk/Debug/grk-cw6.exe differ
diff --git a/grk/Debug/grk-cw6.pdb b/grk/Debug/grk-cw6.pdb
new file mode 100644
index 0000000..a1b8dec
Binary files /dev/null and b/grk/Debug/grk-cw6.pdb differ
diff --git a/grk/cw 6/Debug/Box.obj b/grk/cw 6/Debug/Box.obj
index f3f7c75..d11384e 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..f682209 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..7e23df3 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..12432f4 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..ffeb32f 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..fa4dde5 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.exe.recipe b/grk/cw 6/Debug/grk-cw6.exe.recipe
index 3b7366c..3a2fd02 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
+ D:\grk2024\dgrk-2023-planeta\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..41e8a0e 100644
--- a/grk/cw 6/Debug/grk-cw6.log
+++ b/grk/cw 6/Debug/grk-cw6.log
@@ -1,39 +1,41 @@
-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\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(491,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
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'
+C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
+D:\grk2024\dgrk-2023-planeta\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(72,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(124,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(159,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(261,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(267,52): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
-j:\Downloads\grk\cw 6\src\ex_6_1.hpp(143,50): warning C4305: 'argument': truncation from 'double' to 'T'
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(271,50): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
-j:\Downloads\grk\cw 6\src\ex_6_1.hpp(147,49): warning C4305: 'argument': truncation from 'double' to 'T'
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(275,49): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
-j:\Downloads\grk\cw 6\src\ex_6_1.hpp(151,48): warning C4305: 'argument': truncation from 'double' to 'T'
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(279,48): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
-j:\Downloads\grk\cw 6\src\ex_6_1.hpp(155,48): warning C4305: 'argument': truncation from 'double' to 'T'
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(283,48): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
-j:\Downloads\grk\cw 6\src\ex_6_1.hpp(159,48): warning C4305: 'argument': truncation from 'double' to 'T'
+D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(287,48): warning C4305: "argument": obcięcie z "double" do "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
+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-cw6.vcxproj -> D:\grk2024\dgrk-2023-planeta\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..c2df0a5 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..ac9433d 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..4a66007 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..e94550c 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\|
+PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.19041.0:
+Debug|Win32|D:\grk2024\dgrk-2023-planeta\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
index 70896e5..46b134b 100644
Binary files a/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.write.1u.tlog and b/grk/cw 6/Debug/grk-cw6.tlog/grk-cw6.write.1u.tlog 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..c676852 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..8cc9f2d 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..11fa7b7 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..9abe294 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..7aeb7f2 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..d832cc1 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..0471812 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..4d38469 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..6c8c61d 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/grk-cw6.vcxproj b/grk/cw 6/grk-cw6.vcxproj
index 3573bc1..23af5e3 100644
--- a/grk/cw 6/grk-cw6.vcxproj
+++ b/grk/cw 6/grk-cw6.vcxproj
@@ -41,8 +41,12 @@
-
-
+
+
+
+
+
+
{3952C396-B1C6-44CD-96DD-C1AC15D32978}
diff --git a/grk/cw 6/grk-cw6.vcxproj.filters b/grk/cw 6/grk-cw6.vcxproj.filters
index 85fe689..4b2a24e 100644
--- a/grk/cw 6/grk-cw6.vcxproj.filters
+++ b/grk/cw 6/grk-cw6.vcxproj.filters
@@ -91,12 +91,6 @@
-
- Shader Files
-
-
- Shader Files
-
Shader Files
@@ -109,5 +103,23 @@
Shader Files
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
\ No newline at end of file
diff --git a/grk/cw 6/models/test.obj b/grk/cw 6/models/test.obj
new file mode 100644
index 0000000..79d5676
--- /dev/null
+++ b/grk/cw 6/models/test.obj
@@ -0,0 +1,16 @@
+# Blender v3.2.1 OBJ File: 'untitled.blend'
+# www.blender.org
+mtllib plane.mtl
+o Plane.001
+v -1.000000 -1.000000 -0.000000
+v 1.000000 -1.000000 -0.000000
+v -1.000000 1.000000 0.000000
+v 1.000000 1.000000 0.000000
+vt 0.000000 0.000000
+vt 1.000000 0.000000
+vt 1.000000 1.000000
+vt 0.000000 1.000000
+vn 0.0000 -0.0000 1.0000
+usemtl None
+s off
+f 1/1/1 2/2/1 4/3/1 3/4/1
diff --git a/grk/cw 6/shaders/shader_smap.frag b/grk/cw 6/shaders/shader_smap.frag
new file mode 100644
index 0000000..c7b231b
--- /dev/null
+++ b/grk/cw 6/shaders/shader_smap.frag
@@ -0,0 +1,6 @@
+#version 430 core
+
+void main()
+{
+
+}
\ No newline at end of file
diff --git a/grk/cw 6/shaders/shader_smap.vert b/grk/cw 6/shaders/shader_smap.vert
new file mode 100644
index 0000000..c018240
--- /dev/null
+++ b/grk/cw 6/shaders/shader_smap.vert
@@ -0,0 +1,13 @@
+#version 430 core
+
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec3 vertexNormal;
+layout(location = 2) in vec2 vertexTexCoord;
+
+uniform mat4 viewProjectionMatrix;
+uniform mat4 modelMatrix;
+
+void main()
+{
+ gl_Position = viewProjectionMatrix * modelMatrix * vec4(vertexPosition, 1.0);
+}
\ No newline at end of file
diff --git a/grk/cw 6/shaders/shader_5_sun.frag b/grk/cw 6/shaders/shader_sun.frag
similarity index 100%
rename from grk/cw 6/shaders/shader_5_sun.frag
rename to grk/cw 6/shaders/shader_sun.frag
diff --git a/grk/cw 6/shaders/shader_5_sun.vert b/grk/cw 6/shaders/shader_sun.vert
similarity index 71%
rename from grk/cw 6/shaders/shader_5_sun.vert
rename to grk/cw 6/shaders/shader_sun.vert
index 7d84d62..ba5b529 100644
--- a/grk/cw 6/shaders/shader_5_sun.vert
+++ b/grk/cw 6/shaders/shader_sun.vert
@@ -1,8 +1,8 @@
#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;
diff --git a/grk/cw 6/shaders/test.frag b/grk/cw 6/shaders/test.frag
new file mode 100644
index 0000000..404c2c6
--- /dev/null
+++ b/grk/cw 6/shaders/test.frag
@@ -0,0 +1,12 @@
+#version 330 core
+out vec4 FragColor;
+
+in vec2 tc;
+
+uniform sampler2D depthMap;
+
+void main()
+{
+ float depthValue = texture(depthMap, tc).r;
+ FragColor = vec4(vec3(depthValue+0.5), 1.0);
+}
\ No newline at end of file
diff --git a/grk/cw 6/shaders/test.vert b/grk/cw 6/shaders/test.vert
new file mode 100644
index 0000000..f65f59d
--- /dev/null
+++ b/grk/cw 6/shaders/test.vert
@@ -0,0 +1,14 @@
+#version 430 core
+
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec3 vertexNormal;
+layout(location = 2) in vec2 vertexTexCoord;
+
+
+out vec2 tc;
+
+void main()
+{
+ tc = vertexTexCoord;
+ gl_Position = vec4(vertexPosition*0.9, 1.0);
+}
diff --git a/grk/cw 6/src/ex_6_1.hpp b/grk/cw 6/src/ex_6_1.hpp
index 128d9c7..7890a90 100644
--- a/grk/cw 6/src/ex_6_1.hpp
+++ b/grk/cw 6/src/ex_6_1.hpp
@@ -16,6 +16,11 @@
#include
+namespace models {
+ Core::RenderContext testContext;
+}
+
+
namespace texture {
GLuint earth;
GLuint clouds;
@@ -34,13 +39,20 @@ namespace texture {
GLuint program;
GLuint programSun;
+GLuint programDepth;
GLuint programTex;
+GLuint programTest;
Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext;
Core::RenderContext sphereContext;
+
+glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
+glm::vec3 sunDir = 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(-4.f, 0, 0);
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
GLuint VAO, VBO;
@@ -49,9 +61,26 @@ glm::vec3 shipPos = glm::vec3(-4.f, 0, 0);
glm::vec3 shipDir = glm::vec3(1.f, 0.f, 0.f);
float aspectRatio = 1.f;
+float exposition = 1.f;
+
+glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
+glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
+
+glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
+glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
+glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
+float spotlightPhi = 3.14 / 4;
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8);
+unsigned int depthMapFBO;
+unsigned int depthMap;
+const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
+
+int WIDTH = 500, HEIGHT = 500;
+
+
+
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
@@ -109,6 +138,55 @@ glm::mat4 createPerspectiveMatrix()
return perspectiveMatrix;
}
+void initDepthMap() {
+ glGenFramebuffers(1, &depthMapFBO);
+ glGenTextures(1, &depthMap);
+ glBindTexture(GL_TEXTURE_2D, depthMap);
+ 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, depthMapFBO);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0);
+ glDrawBuffer(GL_NONE);
+ glReadBuffer(GL_NONE);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+}
+
+void renderShadowapSun() {
+ 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, depthMapFBO);
+ //czyszczenie mapy głębokości
+ glClear(GL_DEPTH_BUFFER_BIT);
+ //ustawianie programu
+ glUseProgram(programDepth);
+
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glViewport(0, 0, WIDTH, HEIGHT);
+}
+
+void drawObjectSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
+ glUseProgram(programSun);
+ Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
+ glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
+ glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
+ glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
+ glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
+ Core::DrawContext(context);
+ glUseProgram(0);
+}
+
+
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programTex);
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
@@ -125,11 +203,56 @@ void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::v
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
+
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawContext(context);
glUseProgram(0);
}
+
+void drawObjectDepth(Core::RenderContext& context, glm::mat4 viewProjection, glm::mat4 modelMatrix) {
+ glUseProgram(programDepth);
+
+ glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
+ glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
+
+ glUniformMatrix4fv(glGetUniformLocation(programDepth, "viewProjectionMatrix"), 1, GL_FALSE, (float*)&viewProjectionMatrix);
+ glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
+ Core::DrawContext(context);
+ glUseProgram(0);
+}
+
+void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float roughness, float metallic) {
+
+ glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
+ glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
+ glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
+ glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
+
+ glUniform1f(glGetUniformLocation(program, "exposition"), exposition);
+
+ glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
+ glUniform1f(glGetUniformLocation(program, "metallic"), metallic);
+
+ glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
+
+ glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
+
+ glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
+ glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
+
+ glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
+ glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
+
+ glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
+ 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::DrawContext(context);
+
+}
+
+
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.0f, 0.2f, 1.0f);
@@ -137,6 +260,8 @@ void renderScene(GLFWwindow* window)
glm::mat4 transformation;
float time = glfwGetTime();
+ renderShadowapSun();
+
glm::mat4 sunScale = glm::scale(glm::vec3(1.75));
glm::mat4 mercuryScale = glm::scale(glm::vec3(0.24));
@@ -185,6 +310,26 @@ void renderScene(GLFWwindow* window)
drawObjectTexture(shipContext, shipTranslate * shipRotate * shipScale, texture::ship); //ship
+
+ /*
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glUseProgram(programTest);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, depthMap);
+ Core::DrawContext(models::testContext);
+ */
+
+
+ glm::mat4 lightVP = glm::ortho(-10.f, 10.f, -10.f, 10.f, 1.0f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
+
+ drawObjectDepth(sphereContext, lightVP, sunScale);
+ drawObjectDepth(sphereContext, lightVP, mercuryRotate * mercuryTranslate * mercuryScale);
+ drawObjectDepth(sphereContext, lightVP, venusRotate * venusTranslate * venusScale);
+ drawObjectDepth(sphereContext, lightVP, earthRotate * earthTranslate * earthScale);
+ drawObjectDepth(sphereContext, lightVP, marsRotate * marsTranslate * marsScale);
+ drawObjectDepth(sphereContext, lightVP, shipTranslate * shipRotate * shipScale);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glUseProgram(0);
glfwSwapBuffers(window);
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
@@ -210,11 +355,17 @@ void init(GLFWwindow* window)
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST);
+
+ initDepthMap();
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_sun.vert", "shaders/shader_sun.frag");
+ programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
+ //programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext);
+ //loadModelToContext("./models/test.obj", models::testContext);
texture::earth = Core::LoadTexture("./textures/earth2.png");
texture::clouds = Core::LoadTexture("./textures/clouds.jpg");
diff --git a/grk/grk-cw.sln b/grk/grk-cw.sln
index b9ce046..980da3a 100644
--- a/grk/grk-cw.sln
+++ b/grk/grk-cw.sln
@@ -1,10 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.852
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31019.35
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw1", "cw 1\grk-cw1.vcxproj", "{1B448102-E76C-4347-BDC7-40D02A567DB6}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw6", "cw 6\grk-cw6.vcxproj", "{3952C396-B1C6-44CD-96DD-C1AC15D32978}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
@@ -15,6 +17,10 @@ Global
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Debug|x86.Build.0 = Debug|Win32
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.ActiveCfg = Release|Win32
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.Build.0 = Release|Win32
+ {3952C396-B1C6-44CD-96DD-C1AC15D32978}.Debug|x86.ActiveCfg = Debug|Win32
+ {3952C396-B1C6-44CD-96DD-C1AC15D32978}.Debug|x86.Build.0 = Debug|Win32
+ {3952C396-B1C6-44CD-96DD-C1AC15D32978}.Release|x86.ActiveCfg = Release|Win32
+ {3952C396-B1C6-44CD-96DD-C1AC15D32978}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE