diff --git a/.vs/grk-cw/FileContentIndex/132527c8-18c8-4c52-aff0-d61f6ba50201.vsidx b/.vs/grk-cw/FileContentIndex/132527c8-18c8-4c52-aff0-d61f6ba50201.vsidx
deleted file mode 100644
index 4f52149..0000000
Binary files a/.vs/grk-cw/FileContentIndex/132527c8-18c8-4c52-aff0-d61f6ba50201.vsidx and /dev/null differ
diff --git a/.vs/grk-cw/FileContentIndex/4c4101ca-eb4e-4a4b-a296-2c4b031131f0.vsidx b/.vs/grk-cw/FileContentIndex/4c4101ca-eb4e-4a4b-a296-2c4b031131f0.vsidx
deleted file mode 100644
index b1ee341..0000000
Binary files a/.vs/grk-cw/FileContentIndex/4c4101ca-eb4e-4a4b-a296-2c4b031131f0.vsidx and /dev/null differ
diff --git a/.vs/grk-cw/FileContentIndex/54cc8de3-bb73-4b28-9e65-6683db5fb7f8.vsidx b/.vs/grk-cw/FileContentIndex/54cc8de3-bb73-4b28-9e65-6683db5fb7f8.vsidx
new file mode 100644
index 0000000..c44c9ba
Binary files /dev/null and b/.vs/grk-cw/FileContentIndex/54cc8de3-bb73-4b28-9e65-6683db5fb7f8.vsidx differ
diff --git a/.vs/grk-cw/FileContentIndex/7c37bfc2-c6fe-4cf8-af20-6f46691dbf60.vsidx b/.vs/grk-cw/FileContentIndex/7c37bfc2-c6fe-4cf8-af20-6f46691dbf60.vsidx
deleted file mode 100644
index f1836aa..0000000
Binary files a/.vs/grk-cw/FileContentIndex/7c37bfc2-c6fe-4cf8-af20-6f46691dbf60.vsidx and /dev/null differ
diff --git a/.vs/grk-cw/FileContentIndex/7fa595aa-c0ff-437a-a1ba-6fa4fc6f74ba.vsidx b/.vs/grk-cw/FileContentIndex/7fa595aa-c0ff-437a-a1ba-6fa4fc6f74ba.vsidx
deleted file mode 100644
index b498eb9..0000000
Binary files a/.vs/grk-cw/FileContentIndex/7fa595aa-c0ff-437a-a1ba-6fa4fc6f74ba.vsidx and /dev/null differ
diff --git a/.vs/grk-cw/FileContentIndex/c75bea42-0369-42ba-bf0a-50f03da945a8.vsidx b/.vs/grk-cw/FileContentIndex/c75bea42-0369-42ba-bf0a-50f03da945a8.vsidx
new file mode 100644
index 0000000..295cfc9
Binary files /dev/null and b/.vs/grk-cw/FileContentIndex/c75bea42-0369-42ba-bf0a-50f03da945a8.vsidx differ
diff --git a/.vs/grk-cw/FileContentIndex/read.lock b/.vs/grk-cw/FileContentIndex/read.lock
deleted file mode 100644
index e69de29..0000000
diff --git a/.vs/grk-cw/v17/.suo b/.vs/grk-cw/v17/.suo
index 006ef5a..07d8968 100644
Binary files a/.vs/grk-cw/v17/.suo and b/.vs/grk-cw/v17/.suo differ
diff --git a/.vs/grk-cw/v17/Browse.VC.db b/.vs/grk-cw/v17/Browse.VC.db
index fa752c1..27a11eb 100644
Binary files a/.vs/grk-cw/v17/Browse.VC.db and b/.vs/grk-cw/v17/Browse.VC.db differ
diff --git a/.vs/grk-cw/v17/DocumentLayout.json b/.vs/grk-cw/v17/DocumentLayout.json
new file mode 100644
index 0000000..172086f
--- /dev/null
+++ b/.vs/grk-cw/v17/DocumentLayout.json
@@ -0,0 +1,37 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\",
+ "Documents": [
+ {
+ "AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
+ "RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
+ }
+ ],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 200,
+ "SelectedChildIndex": 0,
+ "Children": [
+ {
+ "$type": "Document",
+ "DocumentIndex": 0,
+ "Title": "ex_7_1.hpp",
+ "DocumentMoniker": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp",
+ "RelativeDocumentMoniker": "projekt_grk\\src\\ex_7_1.hpp",
+ "ToolTip": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp",
+ "RelativeToolTip": "projekt_grk\\src\\ex_7_1.hpp",
+ "ViewState": "AQIAABICAAAAAAAAAAAAAEoCAAAAAAAA",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
+ "WhenOpened": "2024-02-27T10:49:30.827Z",
+ "EditorCaption": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/grk-cw/v17/Solution.VC.db b/.vs/grk-cw/v17/Solution.VC.db
new file mode 100644
index 0000000..4129a00
Binary files /dev/null and b/.vs/grk-cw/v17/Solution.VC.db differ
diff --git a/.vs/grk-cw/v17/fileList.bin b/.vs/grk-cw/v17/fileList.bin
index 3cde5cc..7cb9a9e 100644
Binary files a/.vs/grk-cw/v17/fileList.bin and b/.vs/grk-cw/v17/fileList.bin differ
diff --git a/.vs/grk-cw/v17/ipch/AutoPCH/3af4a585019c4035/MAIN.ipch b/.vs/grk-cw/v17/ipch/AutoPCH/3af4a585019c4035/MAIN.ipch
index 5f94f1f..66658f2 100644
Binary files a/.vs/grk-cw/v17/ipch/AutoPCH/3af4a585019c4035/MAIN.ipch and b/.vs/grk-cw/v17/ipch/AutoPCH/3af4a585019c4035/MAIN.ipch differ
diff --git a/.vs/grk-cw/v17/ipch/AutoPCH/97bba2bfcfe917a6/EX_7_1.ipch b/.vs/grk-cw/v17/ipch/AutoPCH/97bba2bfcfe917a6/EX_7_1.ipch
new file mode 100644
index 0000000..7d7d435
Binary files /dev/null and b/.vs/grk-cw/v17/ipch/AutoPCH/97bba2bfcfe917a6/EX_7_1.ipch differ
diff --git a/.vs/grk-cw/v17/ipch/AutoPCH/f5790c837340269d/VCTMP17672_678192.EX_7_1.00000000.ipch b/.vs/grk-cw/v17/ipch/AutoPCH/f5790c837340269d/VCTMP17672_678192.EX_7_1.00000000.ipch
new file mode 100644
index 0000000..f23fbaf
Binary files /dev/null and b/.vs/grk-cw/v17/ipch/AutoPCH/f5790c837340269d/VCTMP17672_678192.EX_7_1.00000000.ipch differ
diff --git a/Debug/projekt_grk.exe b/Debug/projekt_grk.exe
index 444544b..96cc7c2 100644
Binary files a/Debug/projekt_grk.exe and b/Debug/projekt_grk.exe differ
diff --git a/Debug/projekt_grk.pdb b/Debug/projekt_grk.pdb
index 2285ebb..a042fe1 100644
Binary files a/Debug/projekt_grk.pdb and b/Debug/projekt_grk.pdb differ
diff --git a/projekt_grk/Debug/Box.obj b/projekt_grk/Debug/Box.obj
index a00729f..83b27a8 100644
Binary files a/projekt_grk/Debug/Box.obj and b/projekt_grk/Debug/Box.obj differ
diff --git a/projekt_grk/Debug/Camera.obj b/projekt_grk/Debug/Camera.obj
index 41b65e5..089a96f 100644
Binary files a/projekt_grk/Debug/Camera.obj and b/projekt_grk/Debug/Camera.obj differ
diff --git a/projekt_grk/Debug/Render_Utils.obj b/projekt_grk/Debug/Render_Utils.obj
index 5523aa9..15d3c06 100644
Binary files a/projekt_grk/Debug/Render_Utils.obj and b/projekt_grk/Debug/Render_Utils.obj differ
diff --git a/projekt_grk/Debug/SOIL.obj b/projekt_grk/Debug/SOIL.obj
index 4a5bfcf..f9ea79c 100644
Binary files a/projekt_grk/Debug/SOIL.obj and b/projekt_grk/Debug/SOIL.obj differ
diff --git a/projekt_grk/Debug/Shader_Loader.obj b/projekt_grk/Debug/Shader_Loader.obj
index d05f4be..1ea82ce 100644
Binary files a/projekt_grk/Debug/Shader_Loader.obj and b/projekt_grk/Debug/Shader_Loader.obj differ
diff --git a/projekt_grk/Debug/Texture.obj b/projekt_grk/Debug/Texture.obj
index 83a74a1..9695471 100644
Binary files a/projekt_grk/Debug/Texture.obj and b/projekt_grk/Debug/Texture.obj differ
diff --git a/projekt_grk/Debug/grk-cw7.log b/projekt_grk/Debug/grk-cw7.log
index 8a0418b..d6a33ec 100644
--- a/projekt_grk/Debug/grk-cw7.log
+++ b/projekt_grk/Debug/grk-cw7.log
@@ -1,10 +1,19 @@
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj, grk-cw6.vcxproj, grk-cw7.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
-D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1): message : zobacz poprzednią definicję „APIENTRY”
-D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(96,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
-D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(204,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
-D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(222,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
+ (kompilowanie pliku źródłowego „src/main.cpp”)
+ D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
+ zobacz poprzednią definicję „APIENTRY”
+
+D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(110,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
+ (kompilowanie pliku źródłowego „src/main.cpp”)
+
+D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(332,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
+ (kompilowanie pliku źródłowego „src/main.cpp”)
+
+D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(350,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
+ (kompilowanie pliku źródłowego „src/main.cpp”)
+
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-cw7.vcxproj -> D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\Debug\projekt_grk.exe
diff --git a/projekt_grk/Debug/image_DXT.obj b/projekt_grk/Debug/image_DXT.obj
index 0c483ec..1111394 100644
Binary files a/projekt_grk/Debug/image_DXT.obj and b/projekt_grk/Debug/image_DXT.obj differ
diff --git a/projekt_grk/Debug/image_helper.obj b/projekt_grk/Debug/image_helper.obj
index 1a19ce8..648cdf9 100644
Binary files a/projekt_grk/Debug/image_helper.obj and b/projekt_grk/Debug/image_helper.obj differ
diff --git a/projekt_grk/Debug/main.obj b/projekt_grk/Debug/main.obj
index 56da475..10653ef 100644
Binary files a/projekt_grk/Debug/main.obj and b/projekt_grk/Debug/main.obj differ
diff --git a/projekt_grk/Debug/projekt_grk.tlog/CL.read.1.tlog b/projekt_grk/Debug/projekt_grk.tlog/CL.read.1.tlog
index 1bf5792..64543b6 100644
Binary files a/projekt_grk/Debug/projekt_grk.tlog/CL.read.1.tlog and b/projekt_grk/Debug/projekt_grk.tlog/CL.read.1.tlog differ
diff --git a/projekt_grk/Debug/projekt_grk.tlog/link.read.1.tlog b/projekt_grk/Debug/projekt_grk.tlog/link.read.1.tlog
index 902691d..9ab6916 100644
Binary files a/projekt_grk/Debug/projekt_grk.tlog/link.read.1.tlog and b/projekt_grk/Debug/projekt_grk.tlog/link.read.1.tlog differ
diff --git a/projekt_grk/Debug/projekt_grk.tlog/link.secondary.1.tlog b/projekt_grk/Debug/projekt_grk.tlog/link.secondary.1.tlog
new file mode 100644
index 0000000..878b00d
--- /dev/null
+++ b/projekt_grk/Debug/projekt_grk.tlog/link.secondary.1.tlog
@@ -0,0 +1 @@
+^D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\BOX.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\CAMERA.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\IMAGE_DXT.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\IMAGE_HELPER.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\MAIN.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\RENDER_UTILS.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\SHADER_LOADER.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\SOIL.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\STB_IMAGE_AUG.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\TEXTURE.OBJ
diff --git a/projekt_grk/Debug/projekt_grk.tlog/projekt_grk.lastbuildstate b/projekt_grk/Debug/projekt_grk.tlog/projekt_grk.lastbuildstate
index 76a96e4..75e9b98 100644
--- a/projekt_grk/Debug/projekt_grk.tlog/projekt_grk.lastbuildstate
+++ b/projekt_grk/Debug/projekt_grk.tlog/projekt_grk.lastbuildstate
@@ -1,2 +1,2 @@
-PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.36.32532:TargetPlatformVersion=10.0.22000.0:
+PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22000.0:
Debug|Win32|D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\|
diff --git a/projekt_grk/Debug/stb_image_aug.obj b/projekt_grk/Debug/stb_image_aug.obj
index 499c830..38e53b8 100644
Binary files a/projekt_grk/Debug/stb_image_aug.obj and b/projekt_grk/Debug/stb_image_aug.obj differ
diff --git a/projekt_grk/Debug/vc143.idb b/projekt_grk/Debug/vc143.idb
index 16f0e4c..5093371 100644
Binary files a/projekt_grk/Debug/vc143.idb and b/projekt_grk/Debug/vc143.idb differ
diff --git a/projekt_grk/Debug/vc143.pdb b/projekt_grk/Debug/vc143.pdb
index 5dd3ac2..fc89e8e 100644
Binary files a/projekt_grk/Debug/vc143.pdb and b/projekt_grk/Debug/vc143.pdb differ
diff --git a/projekt_grk/grk-cw7.vcxproj b/projekt_grk/grk-cw7.vcxproj
index 8ed86a3..27d6d99 100644
--- a/projekt_grk/grk-cw7.vcxproj
+++ b/projekt_grk/grk-cw7.vcxproj
@@ -41,6 +41,10 @@
+
+
+
+
diff --git a/projekt_grk/grk-cw7.vcxproj.filters b/projekt_grk/grk-cw7.vcxproj.filters
index 5318bae..5e346f1 100644
--- a/projekt_grk/grk-cw7.vcxproj.filters
+++ b/projekt_grk/grk-cw7.vcxproj.filters
@@ -121,5 +121,17 @@
Shader Files
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
+
+ Shader Files
+
\ No newline at end of file
diff --git a/projekt_grk/shaders/shader_bloom.frag b/projekt_grk/shaders/shader_bloom.frag
new file mode 100644
index 0000000..5c6c0a5
--- /dev/null
+++ b/projekt_grk/shaders/shader_bloom.frag
@@ -0,0 +1,23 @@
+#version 430 core
+out vec4 FragColor;
+
+in vec2 TexCoords;
+
+uniform sampler2D scene;
+uniform sampler2D bloomBlur;
+uniform bool bloom;
+uniform float exposure;
+
+void main()
+{
+ const float gamma = 1.5;
+ vec3 hdrColor = texture(scene, TexCoords).rgb;
+ vec3 bloomColor = texture(bloomBlur, TexCoords).rgb;
+ if(bloom)
+ hdrColor += bloomColor; // additive blending
+ // tone mapping
+ vec3 result = vec3(1.0) - exp(-hdrColor * exposure);
+ // also gamma correct while we're at it
+ result = pow(result, vec3(1.0 / gamma));
+ FragColor = vec4(result, 1.0);
+}
\ No newline at end of file
diff --git a/projekt_grk/shaders/shader_bloom.vert b/projekt_grk/shaders/shader_bloom.vert
new file mode 100644
index 0000000..19a9486
--- /dev/null
+++ b/projekt_grk/shaders/shader_bloom.vert
@@ -0,0 +1,11 @@
+#version 430 core
+layout (location = 7) in vec3 aPos;
+layout (location = 8) in vec2 aTexCoords;
+
+out vec2 TexCoords;
+
+void main()
+{
+ TexCoords = aTexCoords;
+ gl_Position = vec4(aPos, 1.0);
+}
\ No newline at end of file
diff --git a/projekt_grk/shaders/shader_blur.frag b/projekt_grk/shaders/shader_blur.frag
new file mode 100644
index 0000000..a8bd0b0
--- /dev/null
+++ b/projekt_grk/shaders/shader_blur.frag
@@ -0,0 +1,33 @@
+#version 430 core
+out vec4 FragColor;
+
+in vec2 TexCoords;
+
+uniform sampler2D image;
+
+uniform int count;
+uniform bool horizontal;
+uniform float weight[5] = float[] (0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
+
+void main()
+{
+ vec2 tex_offset = 1.0 / textureSize(image, 0); // gets size of single texel
+ vec3 result = texture(image, TexCoords).rgb * weight[0];
+ if(horizontal)
+ {
+ for(int i = 1; i < count; ++i)
+ {
+ result += texture(image, TexCoords + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
+ result += texture(image, TexCoords - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
+ }
+ }
+ else
+ {
+ for(int i = 1; i < 5; ++i)
+ {
+ result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
+ result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
+ }
+ }
+ FragColor = vec4(result, 1.0);
+}
\ No newline at end of file
diff --git a/projekt_grk/shaders/shader_blur.vert b/projekt_grk/shaders/shader_blur.vert
new file mode 100644
index 0000000..75ede81
--- /dev/null
+++ b/projekt_grk/shaders/shader_blur.vert
@@ -0,0 +1,11 @@
+#version 430 core
+layout (location = 0) in vec3 aPos;
+layout (location = 1) in vec2 aTexCoords;
+
+out vec2 TexCoords;
+
+void main()
+{
+ TexCoords = aTexCoords;
+ gl_Position = vec4(aPos, 1.0);
+}
\ No newline at end of file
diff --git a/projekt_grk/shaders/shader_skybox.frag b/projekt_grk/shaders/shader_skybox.frag
index 7052ca9..db0e698 100644
--- a/projekt_grk/shaders/shader_skybox.frag
+++ b/projekt_grk/shaders/shader_skybox.frag
@@ -1,12 +1,21 @@
#version 430 core
+layout (location = 0) out vec4 outColor;
+layout (location = 1) out vec4 BrightColor;
+
uniform samplerCube skybox;
in vec3 texCoord;
-out vec4 out_color;
-
void main()
{
- out_color = texture(skybox,texCoord);
-}
\ No newline at end of file
+ vec4 texColor = texture(skybox, texCoord);
+
+ float brightness = dot(texColor.rgb, vec3(0.2126, 0.7152, 0.0722));
+ if (brightness > 0.2)
+ BrightColor = vec4(texColor.rgb, 1.0);
+ else
+ BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
+
+ outColor = texColor;
+}
diff --git a/projekt_grk/shaders/shader_sun.frag b/projekt_grk/shaders/shader_sun.frag
index e571a5d..23bc9bb 100644
--- a/projekt_grk/shaders/shader_sun.frag
+++ b/projekt_grk/shaders/shader_sun.frag
@@ -1,15 +1,22 @@
#version 430 core
+layout (location = 0) out vec4 outColor;
+layout (location = 1) out vec4 BrightColor;
uniform float exposition;
uniform sampler2D sunTexture;
in vec2 TexCoords;
-out vec4 outColor;
void main()
{
vec3 textureColor = texture(sunTexture, TexCoords).xyz;
vec3 adjustedColor = textureColor * exposition;
-
- outColor = vec4(clamp(adjustedColor, 0.0, 1.0), 1.0);
+ vec3 finalColor = clamp(adjustedColor, 0.0, 1.0);
+ outColor = vec4(finalColor, 1.0);
+
+ float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
+ if(brightness > 0.2)
+ BrightColor = vec4(finalColor, 1.0);
+ else
+ BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
}
diff --git a/projekt_grk/src/ex_7_1.hpp b/projekt_grk/src/ex_7_1.hpp
index 46c7f72..aa75f94 100644
--- a/projekt_grk/src/ex_7_1.hpp
+++ b/projekt_grk/src/ex_7_1.hpp
@@ -55,6 +55,8 @@ GLuint programSun;
GLuint programTex;
GLuint programSkyBox;
GLuint programSpaceShip;
+GLuint programBlur;
+GLuint programBloom;
Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext;
@@ -72,6 +74,18 @@ GLuint VAO,VBO;
float aspectRatio = 1.f;
unsigned int textureID;
+unsigned int hdrFBO;
+unsigned int colorBuffers[2];
+unsigned int pingpongFBO[2];
+unsigned int pingpongColorbuffers[2];
+unsigned int rboDepth;
+
+int HDR_WIDTH;
+int HDR_HEIGHT;
+int blur_count = 5;
+float bloom_exposure = 2.0f;
+bool bloom = true;
+
glm::mat4 createCameraMatrix()
{
@@ -110,6 +124,91 @@ glm::mat4 createPerspectiveMatrix()
return perspectiveMatrix;
}
+unsigned int quadVAO = 0;
+unsigned int quadVBO;
+
+void renderQuad()
+{
+ if (quadVAO == 0)
+ {
+ float quadVertices[] = {
+ -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
+ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
+ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
+ 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
+ };
+ glGenVertexArrays(1, &quadVAO);
+ glGenBuffers(1, &quadVBO);
+
+ glBindVertexArray(quadVAO);
+ glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
+
+ glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
+ // locations 7 i 8 aby nie byo kolizii z shaderem statku
+ glEnableVertexAttribArray(7);
+ glVertexAttribPointer(7, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
+ glEnableVertexAttribArray(8);
+ glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
+ }
+ glBindVertexArray(quadVAO);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glBindVertexArray(0);
+}
+
+void blur(GLFWwindow* window) {
+ glfwGetWindowSize(window, &HDR_WIDTH, &HDR_HEIGHT);
+ glGenFramebuffers(2, pingpongFBO);
+ glGenTextures(2, pingpongColorbuffers);
+ for (unsigned int i = 0; i < 2; i++)
+ {
+ glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]);
+ glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, HDR_WIDTH, HDR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // we clamp to the edge as the blur filter would otherwise sample repeated texture values!
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0);
+ // also check if framebuffers are complete (no need for depth buffer)
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ std::cout << "Framebuffer not complete!" << std::endl;
+ }
+}
+
+void initRBOandHDR(GLFWwindow* window) {
+ glfwGetWindowSize(window, &HDR_WIDTH, &HDR_HEIGHT);
+ glGenFramebuffers(1, &hdrFBO);
+ glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
+ glGenTextures(2, colorBuffers);
+
+ for (unsigned int i = 0; i < 2; i++) {
+ glBindTexture(GL_TEXTURE_2D, colorBuffers[i]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, HDR_WIDTH, HDR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, colorBuffers[i], 0);
+ }
+
+ glGenRenderbuffers(1, &rboDepth);
+ glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, HDR_WIDTH, HDR_HEIGHT);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
+
+ unsigned int attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
+ glDrawBuffers(2, attachments);
+
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ std::cout << "Framebuffer not complete!" << std::endl;
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+}
+
+
+
+
+
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
GLuint prog = program;
glUseProgram(prog);
@@ -149,6 +248,36 @@ void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture
Core::DrawContext(context);
}
+void drawSunBlur() {
+ bool horizontal = true, first_iteration = true;
+ unsigned int amount = 10;
+ glUseProgram(programBlur);
+ glUniform1i(glGetUniformLocation(programBlur, "count"), blur_count);
+ for (unsigned int i = 0; i < amount; i++)
+ {
+ glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
+ glUniform1i(glGetUniformLocation(programBlur, "horizontal"), horizontal);
+ glBindTexture(GL_TEXTURE_2D, first_iteration ? colorBuffers[1] : pingpongColorbuffers[!horizontal]);
+ renderQuad();
+ horizontal = !horizontal;
+ if (first_iteration)
+ first_iteration = false;
+ }
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glUseProgram(programBloom);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, colorBuffers[0]);
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]);
+ glUniform1i(glGetUniformLocation(programBloom, "bloom"), bloom);
+ glUniform1f(glGetUniformLocation(programBloom, "exposure"), bloom_exposure);
+ renderQuad();
+}
+
void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glDisable(GL_DEPTH_TEST);
glUseProgram(programSkyBox);
@@ -190,7 +319,6 @@ void drawSpaceShip(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint t
}
-
void renderPlanet(float time, float orbitRadius, float orbitRotationSpeed, float selfRotationSpeed, float scale, GLuint planetTexture, GLuint normalTexture) {
glm::mat4 planetTransform = glm::rotate(glm::mat4(1.0f), time * orbitRotationSpeed, glm::vec3(0, 1, 0)) // orbitowanie dookoa soca
* glm::translate(glm::vec3(orbitRadius, 0, 0)) // translacja na odp. odlego
@@ -267,6 +395,9 @@ void renderScene(GLFWwindow* window)
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
//skybox
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
@@ -276,7 +407,6 @@ void renderScene(GLFWwindow* window)
//rendering all the planets
renderPlanets();
-
// obliczanie orientacji statku
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));
@@ -297,12 +427,18 @@ void renderScene(GLFWwindow* window)
texture::ship, texture::shipNormal, texture::shipMetalness, texture::shipRoughness
);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ drawSunBlur();
+
+
glUseProgram(0);
glfwSwapBuffers(window);
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
aspectRatio = width / float(height);
+ initRBOandHDR(window);
+ blur(window);
glViewport(0, 0, width, height);
}
void loadModelToContext(std::string path, Core::RenderContext& context)
@@ -321,6 +457,7 @@ void loadModelToContext(std::string path, Core::RenderContext& context)
void init(GLFWwindow* window)
{
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
+ initRBOandHDR(window);
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
@@ -328,6 +465,8 @@ void init(GLFWwindow* window)
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
programSpaceShip = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
+ programBlur = shaderLoader.CreateProgram("shaders/shader_blur.vert", "shaders/shader_blur.frag");
+ programBloom = shaderLoader.CreateProgram("shaders/shader_bloom.vert", "shaders/shader_bloom.frag");
loadModelToContext("./models/sphere.obj", sphereContext);
@@ -360,7 +499,6 @@ void init(GLFWwindow* window)
texture::shipMetalness = Core::LoadTexture("textures/new_spaceship/ship_metalic.jpg");
texture::shipRoughness = Core::LoadTexture("textures/new_spaceship/ship_roughness.jpg");
-
//skybox
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
@@ -393,6 +531,13 @@ void init(GLFWwindow* window)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
//skybox end
+ blur(window);
+
+ glUseProgram(programBlur);
+ glUniform1i(glGetUniformLocation(programBloom, "image"), 0);
+ glUseProgram(programBloom);
+ glUniform1i(glGetUniformLocation(programBloom, "scene"), 0);
+ glUniform1i(glGetUniformLocation(programBloom, "bloomBlur"), 1);
}
void shutdown(GLFWwindow* window)
@@ -400,7 +545,6 @@ void shutdown(GLFWwindow* window)
shaderLoader.DeleteProgram(program);
}
-//obsluga wejscia
void processInput(GLFWwindow* window)
{
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
@@ -432,13 +576,10 @@ void processInput(GLFWwindow* window)
cameraDir = spaceshipDir;
}
-
void renderLoop(GLFWwindow* window) {
while (!glfwWindowShouldClose(window))
{
-
processInput(window);
-
renderScene(window);
glfwPollEvents();
}