Browse Source

updated gl3d a little

meemknight 2 years ago
parent
commit
90fe25e430
37 changed files with 455 additions and 232 deletions
  1. 1 1
      Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.cpp
  2. 2 0
      Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.h
  3. 89 101
      Pika/core/pikaEditor/containersWindow/containersWindow.cpp
  4. 2 3
      Pika/core/pikaEditor/editor/editor.cpp
  5. 2 0
      Pika/core/sharedRuntime/baseContainer.h
  6. 26 1
      Pika/core/sharedRuntime/pikaConsoleManager/pikaConsoleWindow.cpp
  7. 1 3
      Pika/core/sharedRuntime/pikaConsoleManager/pikaConsoleWindow.h
  8. 10 7
      Pika/gameplay/containers/threedtest.h
  9. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Base_Color.png
  10. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Height.png
  11. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Metallic.png
  12. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Mixed_AO.png
  13. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Normal.png
  14. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Normal_OpenGL.png
  15. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Roughness.png
  16. BIN
      Pika/resources/knight/Texture Maps/Extra Maps/Unity/Solus_Knight_mobile_self_ilumin.png
  17. BIN
      Pika/resources/knight/Texture Maps/Original Maps/dark_knight_color.png
  18. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_albedo.png
  19. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_ambient_occlusion.png
  20. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_clear_coat.png
  21. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_metallic.png
  22. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_normal_map.png
  23. BIN
      Pika/resources/knight/Texture Maps/Original Maps/knight_roughness.png
  24. 7 0
      Pika/resources/knight/Texture Maps/RGB Occlusion Metallic Roughness/Read Me.txt
  25. BIN
      Pika/resources/knight/Texture Maps/RGB Occlusion Metallic Roughness/knight_occlusion_metal_roughness.png
  26. BIN
      Pika/resources/knight/dark_knight_color.png
  27. BIN
      Pika/resources/knight/knight_albedo.png
  28. BIN
      Pika/resources/knight/knight_ambient_occlusion.png
  29. BIN
      Pika/resources/knight/knight_clear_coat.png
  30. BIN
      Pika/resources/knight/knight_metallic.png
  31. BIN
      Pika/resources/knight/knight_normal_map.png
  32. BIN
      Pika/resources/knight/knight_occlusion_metal_roughness.png
  33. BIN
      Pika/resources/knight/knight_roughness.png
  34. 0 0
      Pika/resources/knight/uploads_files_1950170_Solus_the_knight.gltf
  35. 4 2
      Pika/resources/logs.txt
  36. 242 68
      Pika/thirdparty/gl3d/gl3d.cpp
  37. 69 46
      Pika/thirdparty/gl3d/gl3d.h

+ 1 - 1
Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.cpp

@@ -151,7 +151,7 @@ namespace pika
 
 
 					if (ImGui::Button("copy file location for engine"))
 					if (ImGui::Button("copy file location for engine"))
 					{
 					{
-						std::string s = "\"" + enginePath + "\"";
+						std::string s =  "PIKA_RESOURCES_PATH \"" + p.path().filename().string() + "\"";
 
 
 						ImGui::SetClipboardText(s.c_str());
 						ImGui::SetClipboardText(s.c_str());
 						ImGui::CloseCurrentPopup();
 						ImGui::CloseCurrentPopup();

+ 2 - 0
Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.h

@@ -1,4 +1,6 @@
 #pragma once
 #pragma once
+
+#include "pikaConfig.h"
 #if !PIKA_SHOULD_REMOVE_IMGUI
 #if !PIKA_SHOULD_REMOVE_IMGUI
 
 
 #include <logs/log.h>
 #include <logs/log.h>

+ 89 - 101
Pika/core/pikaEditor/containersWindow/containersWindow.cpp

@@ -84,151 +84,139 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 
 
 						selectedContainerToLaunch = c.containerName;
 						selectedContainerToLaunch = c.containerName;
 
 
+						ImGui::Text(ICON_FK_PIE_CHART " Memory");
+						ImGui::Separator();
 
 
-						if (ImGui::BeginTabBar("##Tabs for container info", ImGuiTabBarFlags_Reorderable))
-						{
+						ImGui::NewLine();
 
 
-							if (ImGui::BeginTabItem(ICON_FK_PIE_CHART " Memory"))
+						#pragma region total memory requirement
+							size_t totalHeapMemory = c.containerStaticInfo.defaultHeapMemorySize;
+							for (auto i : c.containerStaticInfo.bonusAllocators)
 							{
 							{
-								ImGui::NewLine();
+								totalHeapMemory += i;
+							}
 
 
-							#pragma region total memory requirement
-								size_t totalHeapMemory = c.containerStaticInfo.defaultHeapMemorySize;
-								for (auto i : c.containerStaticInfo.bonusAllocators)
-								{
-									totalHeapMemory += i;
-								}
+							size_t totalMemory = totalHeapMemory + c.containerStructBaseSize;
 
 
-								size_t totalMemory = totalHeapMemory + c.containerStructBaseSize;
+							ImGui::Text("Total Memory requirement: ");
+							ImGui::SameLine();
+							pika::pikaImgui::displayMemorySizeValue(totalMemory);
 
 
-								ImGui::Text("Total Memory requirement: ");
-								ImGui::SameLine();
-								pika::pikaImgui::displayMemorySizeValue(totalMemory);
+							ImGui::Text("Total Heap requirement: ");
+							ImGui::SameLine();
+							pika::pikaImgui::displayMemorySizeValue(totalHeapMemory);
+						#pragma endregion
 
 
-								ImGui::Text("Total Heap requirement: ");
-								ImGui::SameLine();
-								pika::pikaImgui::displayMemorySizeValue(totalHeapMemory);
-							#pragma endregion
+						ImGui::NewLine();
 
 
-								ImGui::NewLine();
+						ImGui::Text("Static Memory requirement: ");
+						ImGui::SameLine();
+						pika::pikaImgui::displayMemorySizeValue(c.containerStructBaseSize);
 
 
-								ImGui::Text("Static Memory requirement: ");
-								ImGui::SameLine();
-								pika::pikaImgui::displayMemorySizeValue(c.containerStructBaseSize);
+						ImGui::Text("Default Heap Memory requirement: ");
+						ImGui::SameLine();
+						pika::pikaImgui::displayMemorySizeValue(c.containerStaticInfo.defaultHeapMemorySize);
 
 
-								ImGui::Text("Default Heap Memory requirement: ");
-								ImGui::SameLine();
-								pika::pikaImgui::displayMemorySizeValue(c.containerStaticInfo.defaultHeapMemorySize);
+						ImGui::Text("Other Heap Memory Allocators count: ");
+						ImGui::SameLine();
+						pika::pikaImgui::displayMemorySizeValue(c.containerStaticInfo.bonusAllocators.size());
 
 
-								ImGui::Text("Other Heap Memory Allocators count: ");
-								ImGui::SameLine();
-								pika::pikaImgui::displayMemorySizeValue(c.containerStaticInfo.bonusAllocators.size());
 
 
+						if (!c.containerStaticInfo.bonusAllocators.empty())
+						{
+							if (ImGui::BeginChild("##heap allocators",
+								{0, 100}, true, ImGuiWindowFlags_AlwaysVerticalScrollbar))
+							{
 
 
-								if (!c.containerStaticInfo.bonusAllocators.empty())
+								for (auto i : c.containerStaticInfo.bonusAllocators)
 								{
 								{
-									if (ImGui::BeginChild("##heap allocators",
-										{0, 100}, true, ImGuiWindowFlags_AlwaysVerticalScrollbar))
-									{
-
-										for (auto i : c.containerStaticInfo.bonusAllocators)
-										{
-											pika::pikaImgui::displayMemorySizeValue(i);
-										}
-
-
-									}
-									ImGui::EndChild();
+									pika::pikaImgui::displayMemorySizeValue(i);
 								}
 								}
 
 
 
 
-								ImGui::EndTabItem();
 							}
 							}
+							ImGui::EndChild();
+						}
 
 
-							if (ImGui::BeginTabItem(ICON_FK_PLUS_SQUARE_O" Launch"))
-							{
-								ImGui::NewLine();
 
 
 
 
-								if (!selectedContainerToLaunch.empty()
-									&& ImGui::Button(ICON_FK_PLAY " Launch a default configuration"))
+							ImGui::NewLine();
+							ImGui::Text(ICON_FK_PLUS_SQUARE_O " Launch");
+							ImGui::Separator();
+
+							ImGui::NewLine();
+
+							if (!selectedContainerToLaunch.empty()
+								&& ImGui::Button(ICON_FK_PLAY " Launch a default configuration"))
+							{
+								if (createAtSpecificMemoryRegion)
 								{
 								{
-									if (createAtSpecificMemoryRegion)
-									{
-										containerManager.createContainer(selectedContainerToLaunch, loadedDll,
-											logManager, imguiIdsManager, consoleWindow, pika::TB(1));
-									}
-									else
-									{
-										containerManager.createContainer(selectedContainerToLaunch, loadedDll, logManager,
-											imguiIdsManager, consoleWindow);
-									}
+									containerManager.createContainer(selectedContainerToLaunch, loadedDll,
+										logManager, imguiIdsManager, consoleWindow, pika::TB(1));
+								}
+								else
+								{
+									containerManager.createContainer(selectedContainerToLaunch, loadedDll, logManager,
+										imguiIdsManager, consoleWindow);
 								}
 								}
+							}
 
 
-								ImGui::Checkbox("allocate at specific memory region", &createAtSpecificMemoryRegion);
+							ImGui::Checkbox("allocate at specific memory region", &createAtSpecificMemoryRegion);
 
 
 
 
-								//ImGui::NewLine();
+							//ImGui::NewLine();
 
 
+							{
+								static int currentSelectedSnapshot = 0;
+								auto snapshots = pika::getAvailableSnapshotsAnyMemoryPosition(c);
+
+								if (!selectedContainerToLaunch.empty()
+									&& ImGui::Button(ICON_FK_PICTURE_O " Launch a snapshot"))
 								{
 								{
-									static int currentSelectedSnapshot = 0;
-									auto snapshots = pika::getAvailableSnapshotsAnyMemoryPosition(c);
+									auto s = snapshots[currentSelectedSnapshot];
 
 
-									if (!selectedContainerToLaunch.empty()
-										&& ImGui::Button(ICON_FK_PICTURE_O " Launch a snapshot"))
+									auto memPos = getSnapshotMemoryPosition(s.c_str());
+
+									if (memPos == nullptr)
+									{
+										logManager.log("Failes to get snapshot info", pika::logError);
+									}
+									else
 									{
 									{
-										auto s = snapshots[currentSelectedSnapshot];
 
 
-										auto memPos = getSnapshotMemoryPosition(s.c_str());
+										auto c = containerManager.createContainer(
+											selectedContainerToLaunch, loadedDll, logManager,
+											imguiIdsManager, consoleWindow, (size_t)memPos);
 
 
-										if (memPos == nullptr)
+										//no need to log error since create container does that
+										if (c != 0)
 										{
 										{
-											logManager.log("Failes to get snapshot info", pika::logError);
-										}
-										else
-										{
-
-											auto c = containerManager.createContainer(
-												selectedContainerToLaunch, loadedDll, logManager,
-												imguiIdsManager, consoleWindow, (size_t)memPos);
-
-											//no need to log error since create container does that
-											if (c != 0)
+											if (!containerManager.setSnapshotToContainer(c,
+												s.c_str(), logManager, imguiIdsManager))
 											{
 											{
-												if (!containerManager.setSnapshotToContainer(c,
-													s.c_str(), logManager, imguiIdsManager))
-												{
-													containerManager.destroyContainer(c, loadedDll, logManager);
-												}
+												containerManager.destroyContainer(c, loadedDll, logManager);
 											}
 											}
-
-
 										}
 										}
 
 
-										
-									
-									
-									}
-
-
-									auto contentSize = ImGui::GetItemRectSize();
-									contentSize.y -= ImGui::GetFrameHeightWithSpacing();
-									//contentSize.x /= 2;
 
 
-									ImGui::ListWithFilter("##list box snapshots", &currentSelectedSnapshot,
-										filterSnapshots, sizeof(filterSnapshots),
-										snapshots, contentSize);
-								}
+									}
 
 
+									
 								
 								
+								
+								}
 
 
-								ImGui::EndTabItem();
-							}
 
 
-							ImGui::EndTabBar();
-						}
+								auto contentSize = ImGui::GetItemRectSize();
+								contentSize.y -= ImGui::GetFrameHeightWithSpacing();
+								//contentSize.x /= 2;
 
 
+								ImGui::ListWithFilter("##list box snapshots", &currentSelectedSnapshot,
+									filterSnapshots, sizeof(filterSnapshots),
+									snapshots, contentSize);
+							}
 
 
+								
 
 
 					}
 					}
 					else
 					else

+ 2 - 3
Pika/core/pikaEditor/editor/editor.cpp

@@ -4,6 +4,7 @@
 //https://github.com/meemknight/PikaEngine
 //https://github.com/meemknight/PikaEngine
 //////////////////////////////////////////
 //////////////////////////////////////////
 
 
+#include "pikaConfig.h"
 #if !PIKA_SHOULD_REMOVE_EDITOR
 #if !PIKA_SHOULD_REMOVE_EDITOR
 
 
 #include "editor.h"
 #include "editor.h"
@@ -25,7 +26,6 @@
 #define ASSET_MANAGER_WINDOW ICON_FK_FILES_O " Asset manager"
 #define ASSET_MANAGER_WINDOW ICON_FK_FILES_O " Asset manager"
 #define OPENGL_ERRORS_WINDOW ICON_FK_EXCLAMATION_TRIANGLE " opengl errors"
 #define OPENGL_ERRORS_WINDOW ICON_FK_EXCLAMATION_TRIANGLE " opengl errors"
 
 
-#if !PIKA_SHOULD_REMOVE_EDITOR
 
 
 void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui::ImGuiIdsManager &imguiIDManager)
 void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui::ImGuiIdsManager &imguiIDManager)
 {
 {
@@ -244,7 +244,7 @@ void pika::Editor::update(const pika::Input &input,
 #pragma region console
 #pragma region console
 	if (windowFlags.consoleWindow)
 	if (windowFlags.consoleWindow)
 	{
 	{
-		consoleWindow.update(logs, windowFlags.consoleWindow);
+		consoleWindow.update(windowFlags.consoleWindow);
 	}
 	}
 #pragma endregion
 #pragma endregion
 
 
@@ -280,4 +280,3 @@ void pika::Editor::saveFlagsData()
 
 
 #endif
 #endif
 
 
-#endif

+ 2 - 0
Pika/core/sharedRuntime/baseContainer.h

@@ -38,6 +38,8 @@ struct RequestedContainerInfo
 
 
 	pika::ConsoleWindow *consoleWindow = nullptr;
 	pika::ConsoleWindow *consoleWindow = nullptr;
 
 
+	//todo add logs here
+
 	//returns true if succeded (can return false if console is disabeled)
 	//returns true if succeded (can return false if console is disabeled)
 	bool consoleWrite(const char* c)
 	bool consoleWrite(const char* c)
 	{
 	{

+ 26 - 1
Pika/core/sharedRuntime/pikaConsoleManager/pikaConsoleWindow.cpp

@@ -20,7 +20,7 @@ namespace pika
 		imguiId = idManager.getImguiIds();
 		imguiId = idManager.getImguiIds();
 	}
 	}
 
 
-	void ConsoleWindow::update(pika::LogManager &logManager, bool &open)
+	void ConsoleWindow::update(bool &open)
 	{
 	{
 
 
 		//s += buffer->get;
 		//s += buffer->get;
@@ -96,4 +96,29 @@ namespace pika
 
 
 };
 };
 
 
+#else
+
+#include "pikaConsoleWindow.h"
+
+//todo log console in production flag
+
+namespace pika
+{
+
+
+
+	void ConsoleWindow::init(pika::pikaImgui::ImGuiIdsManager &idManager)
+	{
+	}
+
+	void ConsoleWindow::update(bool &open)
+	{
+	}
+
+	void ConsoleWindow::write(const char *c)
+	{
+	}
+
+};
+
 #endif
 #endif

+ 1 - 3
Pika/core/sharedRuntime/pikaConsoleManager/pikaConsoleWindow.h

@@ -1,7 +1,6 @@
 #pragma once
 #pragma once
 
 
 #include <pikaConfig.h>
 #include <pikaConfig.h>
-#if !PIKA_SHOULD_REMOVE_EDITOR
 
 
 #include <pikaImgui/pikaImgui.h>
 #include <pikaImgui/pikaImgui.h>
 #include <logs/log.h>
 #include <logs/log.h>
@@ -15,7 +14,7 @@ namespace pika
 
 
 		void init(pika::pikaImgui::ImGuiIdsManager &idManager);
 		void init(pika::pikaImgui::ImGuiIdsManager &idManager);
 
 
-		void update(pika::LogManager &logManager, bool &open);
+		void update(bool &open);
 
 
 		static constexpr char *ICON = ICON_FK_TERMINAL;
 		static constexpr char *ICON = ICON_FK_TERMINAL;
 		static constexpr char *NAME = "console";
 		static constexpr char *NAME = "console";
@@ -36,4 +35,3 @@ namespace pika
 
 
 };
 };
 
 
-#endif

+ 10 - 7
Pika/gameplay/containers/threedtest.h

@@ -12,7 +12,7 @@ void inline errorCallbackCustom(std::string err, void *userData)
 {
 {
 	RequestedContainerInfo *data = (RequestedContainerInfo*)userData;
 	RequestedContainerInfo *data = (RequestedContainerInfo*)userData;
 
 
-	data->consoleWrite(err.c_str());
+	data->consoleWrite((err+"\n").c_str());
 }
 }
 
 
 std::string inline readEntireFileCustom(const char *fileName, bool &couldNotOpen, void *userData)
 std::string inline readEntireFileCustom(const char *fileName, bool &couldNotOpen, void *userData)
@@ -100,13 +100,15 @@ struct ThreeDTest: public Container
 		//glDebugMessageCallback(gl3d::glDebugOutput, &renderer.errorReporter);
 		//glDebugMessageCallback(gl3d::glDebugOutput, &renderer.errorReporter);
 		//glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
 		//glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
 
 
+
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
 		renderer.fileOpener.readEntireFileCallback = readEntireFileCustom;
 		renderer.fileOpener.readEntireFileCallback = readEntireFileCustom;
 		renderer.fileOpener.fileExistsCallback = defaultFileExistsCustom;
 		renderer.fileOpener.fileExistsCallback = defaultFileExistsCustom;
 
 
-		renderer.init(1, 1, requestedInfo.requestedFBO.fbo, PIKA_RESOURCES_PATH "BRDFintegrationMap.png");
+		renderer.init(1, 1, PIKA_RESOURCES_PATH "BRDFintegrationMap.png", requestedInfo.requestedFBO.fbo);
+
 		//renderer.skyBox = renderer.atmosfericScattering({0.2,1,0.3}, {0.9,0.1,0.1}, {0.4, 0.4, 0.8}, 0.8f); //todo a documentation
 		//renderer.skyBox = renderer.atmosfericScattering({0.2,1,0.3}, {0.9,0.1,0.1}, {0.4, 0.4, 0.8}, 0.8f); //todo a documentation
 		//todo api for skybox stuff
 		//todo api for skybox stuff
 		//renderer.skyBox.color = {0.2,0.3,0.9};
 		//renderer.skyBox.color = {0.2,0.3,0.9};
@@ -119,11 +121,12 @@ struct ThreeDTest: public Container
 			PIKA_RESOURCES_PATH "/skyBoxes/ocean/front.jpg",
 			PIKA_RESOURCES_PATH "/skyBoxes/ocean/front.jpg",
 			PIKA_RESOURCES_PATH "/skyBoxes/ocean/back.jpg"};
 			PIKA_RESOURCES_PATH "/skyBoxes/ocean/back.jpg"};
 
 
-		renderer.skyBox = renderer.loadSkyBox(names, requestedInfo.requestedFBO.fbo);
+		renderer.skyBox = renderer.loadSkyBox(names);
 		//renderer.skyBox.color = {0.2,0.3,0.8};
 		//renderer.skyBox.color = {0.2,0.3,0.8};
 
 
-		helmetModel = renderer.loadModel(PIKA_RESOURCES_PATH "helmet/helmet.obj", requestedInfo.requestedFBO.fbo);
-		
+		helmetModel = renderer.loadModel(PIKA_RESOURCES_PATH "helmet/helmet.obj");
+		//helmetModel = renderer.loadModel(PIKA_RESOURCES_PATH "/knight/uploads_files_1950170_Solus_the_knight.gltf", 1.f);
+
 		gl3d::Transform t;
 		gl3d::Transform t;
 		t.position = {0, 0, -3};
 		t.position = {0, 0, -3};
 		t.rotation = {1.5, 0 , 0};
 		t.rotation = {1.5, 0 , 0};
@@ -135,7 +138,7 @@ struct ThreeDTest: public Container
 	void update(pika::Input input, pika::WindowState windowState,
 	void update(pika::Input input, pika::WindowState windowState,
 		RequestedContainerInfo &requestedInfo)
 		RequestedContainerInfo &requestedInfo)
 	{
 	{
-		//glDebugMessageCallback(gl3d::glDebugOutput, &renderer.errorReporter);
+
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
@@ -171,7 +174,7 @@ struct ThreeDTest: public Container
 		}
 		}
 		
 		
 
 
-		renderer.render(input.deltaTime, requestedInfo.requestedFBO.fbo);
+		renderer.render(input.deltaTime);
 
 
 
 
 		glDisable(GL_DEPTH_TEST);
 		glDisable(GL_DEPTH_TEST);

BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Base_Color.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Height.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Metallic.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Mixed_AO.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Normal.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Normal_OpenGL.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Renderers/Solus_Knight_Roughness.png


BIN
Pika/resources/knight/Texture Maps/Extra Maps/Unity/Solus_Knight_mobile_self_ilumin.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/dark_knight_color.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_albedo.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_ambient_occlusion.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_clear_coat.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_metallic.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_normal_map.png


BIN
Pika/resources/knight/Texture Maps/Original Maps/knight_roughness.png


+ 7 - 0
Pika/resources/knight/Texture Maps/RGB Occlusion Metallic Roughness/Read Me.txt

@@ -0,0 +1,7 @@
+
+This texture uses color channels such as metallic, roughness and ambient occlusion. 
+This saves the need for a map for each function.
+
+Red > Ambient Occlusion
+Green > Roughness
+Blue > Mettalic

BIN
Pika/resources/knight/Texture Maps/RGB Occlusion Metallic Roughness/knight_occlusion_metal_roughness.png


BIN
Pika/resources/knight/dark_knight_color.png


BIN
Pika/resources/knight/knight_albedo.png


BIN
Pika/resources/knight/knight_ambient_occlusion.png


BIN
Pika/resources/knight/knight_clear_coat.png


BIN
Pika/resources/knight/knight_metallic.png


BIN
Pika/resources/knight/knight_normal_map.png


BIN
Pika/resources/knight/knight_occlusion_metal_roughness.png


BIN
Pika/resources/knight/knight_roughness.png


File diff suppressed because it is too large
+ 0 - 0
Pika/resources/knight/uploads_files_1950170_Solus_the_knight.gltf


+ 4 - 2
Pika/resources/logs.txt

@@ -1,2 +1,4 @@
-#2022-12-21 11:07:19: Created container: Gameplay
-#2022-12-21 11:08:30: Destroyed continer: Gameplay #1
+#2023-01-23 16:28:03: Created container: Gameplay
+#2023-01-23 16:28:17: Created container: ThreeDTest
+#2023-01-23 16:28:21: Destroyed continer: Gameplay #1
+#2023-01-23 16:28:21: Destroyed continer: ThreeDTest #2

+ 242 - 68
Pika/thirdparty/gl3d/gl3d.cpp

@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 //gl32 --Vlad Luta -- 
 //gl32 --Vlad Luta -- 
-//built on 2022-11-22
+//built on 2023-01-23
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 
 
 #include "gl3d.h"
 #include "gl3d.h"
@@ -31291,11 +31291,12 @@ void gl3d::ErrorReporter::callErrorCallback(std::string s)
 
 
 void gl3d::defaultErrorCallback(std::string err, void *userData)
 void gl3d::defaultErrorCallback(std::string err, void *userData)
 {
 {
+	//std::cout << err << "\n";
 }
 }
 
 
 std::string gl3d::defaultReadEntireFile(const char* fileName, bool &couldNotOpen, void *userData)
 std::string gl3d::defaultReadEntireFile(const char* fileName, bool &couldNotOpen, void *userData)
 {
 {
-	return {};
+	return "";
 }
 }
 
 
 std::vector<char> gl3d::defaultReadEntireFileBinary(const char *fileName, bool &couldNotOpen, void *userData)
 std::vector<char> gl3d::defaultReadEntireFileBinary(const char *fileName, bool &couldNotOpen, void *userData)
@@ -31305,7 +31306,7 @@ std::vector<char> gl3d::defaultReadEntireFileBinary(const char *fileName, bool &
 
 
 bool gl3d::defaultFileExists(const char *fileName, void *userData)
 bool gl3d::defaultFileExists(const char *fileName, void *userData)
 {
 {
-	return {};
+	return 0;
 }
 }
 
 
 #pragma endregion
 #pragma endregion
@@ -31814,12 +31815,13 @@ namespace gl3d
 
 
 		//std::pair< std::string, const char*>{"name", "value"}
 		//std::pair< std::string, const char*>{"name", "value"}
 		//#pragma shaderSources
 		//#pragma shaderSources
-      std::pair<std::string, const char*>{"ssao.frag", "#version 330 core\n"
+      std::pair<std::string, const char*>{"ssao.frag", "#version 330 core\n"
 "out float fragColor;\n"
 "out float fragColor;\n"
 "noperspective in highp vec2 v_texCoords;\n"
 "noperspective in highp vec2 v_texCoords;\n"
 "uniform sampler2D u_gPosition;\n"
 "uniform sampler2D u_gPosition;\n"
 "uniform isampler2D u_gNormal;\n"
 "uniform isampler2D u_gNormal;\n"
 "uniform sampler2D u_texNoise;\n"
 "uniform sampler2D u_texNoise;\n"
+"uniform sampler2D u_depthBuffer;\n"
 "uniform vec3 samples[64];\n"
 "uniform vec3 samples[64];\n"
 "uniform mat4 u_projection; \n"
 "uniform mat4 u_projection; \n"
 "uniform mat4 u_view; \n"
 "uniform mat4 u_view; \n"
@@ -31838,14 +31840,29 @@ namespace gl3d
 "ret -= 1.f;\n"
 "ret -= 1.f;\n"
 "return normalize(ret);\n"
 "return normalize(ret);\n"
 "}\n"
 "}\n"
+"uniform float u_farPlane;\n"
+"uniform float u_closePlane;\n"
+"vec3 viewSpace(vec2 vTexCoord)\n"
+"{\n"
+"float z = texture2D(u_depthBuffer, vTexCoord).x;  \n"
+"float z_n = 2.0 * z - 1.0;\n"
+"float z_e = 2.0 * u_closePlane * u_farPlane / (u_farPlane + u_closePlane - z_n * (u_farPlane - u_closePlane));\n"
+"vec3 retVector = vec3(1,1,1);\n"
+"return retVector * z_e;\n"
+"float x = vTexCoord.x * 2 - 1;\n"
+"float y = (1 - vTexCoord.y) * 2 - 1;\n"
+"vec4 vProjectedPos = vec4(x, y, z, 1.0f);\n"
+"vec4 vPositionVS = inverse(u_projection) * vProjectedPos;  \n"
+"return vPositionVS.xyz / vPositionVS.w;  \n"
+"}\n"
 "void main()\n"
 "void main()\n"
 "{\n"
 "{\n"
 "vec2 screenSize = textureSize(u_gPosition, 0).xy/2.f; \n"
 "vec2 screenSize = textureSize(u_gPosition, 0).xy/2.f; \n"
 "vec2 noiseScale = vec2(screenSize.x/4.0, screenSize.y/4.0);\n"
 "vec2 noiseScale = vec2(screenSize.x/4.0, screenSize.y/4.0);\n"
 "vec2 noisePos = v_texCoords * noiseScale;\n"
 "vec2 noisePos = v_texCoords * noiseScale;\n"
 "vec3 fragPos   = texture(u_gPosition, v_texCoords).xyz;\n"
 "vec3 fragPos   = texture(u_gPosition, v_texCoords).xyz;\n"
-"vec3 normal    = vec3(transpose(inverse(mat3(u_view))) * \n"
-"fromuShortToFloat(texture(u_gNormal, v_texCoords).xyz));\n"
+"vec3 normal    = normalize( vec3(transpose(inverse(mat3(u_view))) * \n"
+"fromuShortToFloat(texture(u_gNormal, v_texCoords).xyz)) );\n"
 "vec3 randomVec = texture2D(u_texNoise, noisePos).xyz; \n"
 "vec3 randomVec = texture2D(u_texNoise, noisePos).xyz; \n"
 "vec3 tangent   = normalize(randomVec - normal * dot(randomVec, normal));\n"
 "vec3 tangent   = normalize(randomVec - normal * dot(randomVec, normal));\n"
 "vec3 bitangent = cross(normal, tangent);\n"
 "vec3 bitangent = cross(normal, tangent);\n"
@@ -32731,6 +32748,83 @@ namespace gl3d
 "float roughness = texture(u_roughness, v_texCoords).r;\n"
 "float roughness = texture(u_roughness, v_texCoords).r;\n"
 "float ambient = texture(u_ambient, v_texCoords).r;\n"
 "float ambient = texture(u_ambient, v_texCoords).r;\n"
 "fragColor = vec4(roughness, metallic, ambient, 1);\n"
 "fragColor = vec4(roughness, metallic, ambient, 1);\n"
+"}\n"},
+
+      std::pair<std::string, const char*>{"hbao.frag", "#version 330 core\n"
+"out float fragColor;\n"
+"noperspective in highp vec2 v_texCoords;\n"
+"uniform sampler2D u_gPosition;\n"
+"uniform isampler2D u_gNormal;\n"
+"uniform sampler2D u_texNoise;\n"
+"uniform mat4 u_projection; \n"
+"uniform mat4 u_view; \n"
+"const float INFINITY = 1.f/0.f;\n"
+"vec3 fromuShortToFloat(ivec3 a)\n"
+"{\n"
+"vec3 ret = a;\n"
+"ret /= 65536;\n"
+"ret *= 2.f;\n"
+"ret -= 1.f;\n"
+"return normalize(ret);\n"
+"}\n"
+"float saturate(float a)\n"
+"{\n"
+"return min(max(a,0),1);\n"
+"}\n"
+"vec2 computeAO(vec3 normal, vec2 direction, vec2 screenSize, vec3 fragPos)\n"
+"{\n"
+"float RAD = 0.05;\n"
+"float RAD_FOR_DIRECTION = length( direction*vec2(10.0) / (vec2(abs(fragPos.z))*screenSize));\n"
+"vec3 viewVector = normalize(fragPos);\n"
+"vec3 leftDirection = cross(viewVector, vec3(direction,0));\n"
+"vec3 projectedNormal = normal - dot(leftDirection, normal) * leftDirection;\n"
+"float projectedLen = length(projectedNormal);\n"
+"projectedNormal /= projectedLen;\n"
+"vec3 tangent = cross(projectedNormal, leftDirection);\n"
+"const float bias = (3.141592/360)*20.f;\n"
+"float tangentAngle = atan(tangent.z / length(tangent.xy));\n"
+"float sinTangentAngle = sin(tangentAngle + bias);\n"
+"vec2 texelSize = vec2(1.f,1.f) / screenSize;\n"
+"float highestZ = -INFINITY;\n"
+"vec3 foundPos = vec3(0,0,-INFINITY);\n"
+"for(int i=2; i<=10; i++)\n"
+"{\n"
+"vec2 marchPosition = v_texCoords + i*texelSize*direction;\n"
+"vec3 fragPosMarch = texture(u_gPosition, marchPosition).xyz;\n"
+"vec3 hVector = normalize(fragPosMarch-fragPos); \n"
+"float rangeCheck = 1 - saturate(length(fragPosMarch-fragPos) / RAD-1);\n"
+"if(hVector.z > highestZ && length(fragPosMarch-fragPos) < RAD)\n"
+"{\n"
+"highestZ = hVector.z;\n"
+"foundPos = fragPosMarch;\n"
+"}\n"
+"}\n"
+"vec3 horizonVector = (foundPos - fragPos);\n"
+"float horizonAngle = atan(horizonVector.z/length(horizonVector.xy));\n"
+"float sinHorizonAngle = sin(horizonAngle);	\n"
+"vec2 rez = vec2(saturate((sinHorizonAngle - sinTangentAngle))/2, projectedLen);\n"
+"return rez;\n"
+"}\n"
+"void main()\n"
+"{\n"
+"vec2 screenSize = textureSize(u_gPosition, 0).xy/2.f; \n"
+"vec2 noiseScale = vec2(screenSize.x/4.0, screenSize.y/4.0);\n"
+"vec2 noisePos = v_texCoords * noiseScale;\n"
+"vec3 fragPos   = texture(u_gPosition, v_texCoords).xyz; \n"
+"if(fragPos.z == -INFINITY){fragColor = 1; return;}\n"
+"vec3 normal    = normalize( vec3( \n"
+"transpose(inverse(mat3(u_view))) * \n"
+"fromuShortToFloat(texture(u_gNormal, v_texCoords).xyz)\n"
+"));\n"
+"vec2 randomVec = vec2(0,1);\n"
+"vec2 rez = vec2(0,0);\n"
+"vec3 viewVector = normalize(fragPos);\n"
+"rez += computeAO(normal, vec2(randomVec), screenSize, fragPos);\n"
+"rez += computeAO(normal, -vec2(randomVec), screenSize, fragPos);\n"
+"rez += computeAO(normal, vec2(-randomVec.y,randomVec.x), screenSize, fragPos);\n"
+"rez += computeAO(normal, vec2(randomVec.y, -randomVec.x), screenSize, fragPos);\n"
+"rez.x /= rez.y;\n"
+"fragColor = 1.f - rez.x;\n"
 "}\n"},
 "}\n"},
 
 
       std::pair<std::string, const char*>{"zPrePass.vert", "#version 430\n"
       std::pair<std::string, const char*>{"zPrePass.vert", "#version 430\n"
@@ -32984,7 +33078,7 @@ namespace gl3d
 "vec3 kS = F; \n"
 "vec3 kS = F; \n"
 "vec3 kD = vec3(1.0) - kS; \n"
 "vec3 kD = vec3(1.0) - kS; \n"
 "kD *= 1.0 - metallic;	\n"
 "kD *= 1.0 - metallic;	\n"
-"vec3 diffuse = fDiffuse(color.rgb);\n"
+"vec3 diffuse = fDiffuseOrenNayar2(color.rgb, roughness, lightDirection, viewDir, normal);\n"
 "float NdotL = max(dot(normal, lightDirection), 0.0);        \n"
 "float NdotL = max(dot(normal, lightDirection), 0.0);        \n"
 "return (kD * diffuse + specular) * radiance * NdotL;\n"
 "return (kD * diffuse + specular) * radiance * NdotL;\n"
 "}\n"
 "}\n"
@@ -35919,8 +36013,10 @@ namespace gl3d
 {
 {
 	
 	
 
 
-	void Renderer3D::init(int x, int y, GLuint frameBuffer, const char *BRDFIntegrationMapFileLocation)
+	void Renderer3D::init(int x, int y, const char *BRDFIntegrationMapFileLocation, GLuint frameBuffer)
 	{
 	{
+		this->frameBuffer = frameBuffer;
+
 		internal.w = x; internal.h = y;
 		internal.w = x; internal.h = y;
 		internal.adaptiveW = x;
 		internal.adaptiveW = x;
 		internal.adaptiveH = y;
 		internal.adaptiveH = y;
@@ -35954,6 +36050,7 @@ namespace gl3d
 
 
 		internal.gBuffer.create(x, y, errorReporter, frameBuffer);
 		internal.gBuffer.create(x, y, errorReporter, frameBuffer);
 		internal.ssao.create(x, y, errorReporter, fileOpener, frameBuffer);
 		internal.ssao.create(x, y, errorReporter, fileOpener, frameBuffer);
+		internal.hbao.create(errorReporter, fileOpener, frameBuffer);
 		postProcess.create(x, y, errorReporter, fileOpener, frameBuffer);
 		postProcess.create(x, y, errorReporter, fileOpener, frameBuffer);
 		directionalShadows.create(frameBuffer);
 		directionalShadows.create(frameBuffer);
 		spotShadows.create(frameBuffer);
 		spotShadows.create(frameBuffer);
@@ -35994,7 +36091,7 @@ namespace gl3d
 
 
 	}
 	}
 	
 	
-	Material Renderer3D::createMaterial(GLuint frameBuffer, glm::vec4 kd,
+	Material Renderer3D::createMaterial(glm::vec4 kd,
 		float roughness, float metallic, float ao, std::string name,
 		float roughness, float metallic, float ao, std::string name,
 		gl3d::Texture albedoTexture, gl3d::Texture normalTexture, gl3d::Texture roughnessTexture, gl3d::Texture metallicTexture,
 		gl3d::Texture albedoTexture, gl3d::Texture normalTexture, gl3d::Texture roughnessTexture, gl3d::Texture metallicTexture,
 		gl3d::Texture occlusionTexture, gl3d::Texture emmisiveTexture)
 		gl3d::Texture occlusionTexture, gl3d::Texture emmisiveTexture)
@@ -36015,8 +36112,7 @@ namespace gl3d
 		textureData.emissiveTexture = emmisiveTexture;
 		textureData.emissiveTexture = emmisiveTexture;
 
 
 
 
-		textureData.pbrTexture = createPBRTexture(roughnessTexture, metallicTexture, occlusionTexture,
-			frameBuffer);
+		textureData.pbrTexture = createPBRTexture(roughnessTexture, metallicTexture, occlusionTexture);
 
 
 
 
 		internal.materialIndexes.push_back(id);
 		internal.materialIndexes.push_back(id);
@@ -36030,7 +36126,7 @@ namespace gl3d
 
 
 	}
 	}
 
 
-	Material Renderer3D::createMaterial(Material m, GLuint frameBuffer)
+	Material Renderer3D::createMaterial(Material m)
 	{
 	{
 		auto newM = createMaterial(frameBuffer);
 		auto newM = createMaterial(frameBuffer);
 		copyMaterialData(newM, m);
 		copyMaterialData(newM, m);
@@ -36047,7 +36143,7 @@ namespace gl3d
 	gl3d::Material createMaterialFromLoadedData(gl3d::Renderer3D &renderer, 
 	gl3d::Material createMaterialFromLoadedData(gl3d::Renderer3D &renderer, 
 		objl::Material &mat, const std::string &path, GLuint frameBuffer)
 		objl::Material &mat, const std::string &path, GLuint frameBuffer)
 	{
 	{
-		auto m = renderer.createMaterial(frameBuffer, mat.Kd, mat.roughness,
+		auto m = renderer.createMaterial(mat.Kd, mat.roughness,
 			mat.metallic, mat.ao, mat.name);
 			mat.metallic, mat.ao, mat.name);
 
 
 		stbi_set_flip_vertically_on_load(true);
 		stbi_set_flip_vertically_on_load(true);
@@ -36372,7 +36468,7 @@ namespace gl3d
 		return m;
 		return m;
 	}
 	}
 
 
-	std::vector<Material> Renderer3D::loadMaterial(std::string file, GLuint frameBuffer)
+	std::vector<Material> Renderer3D::loadMaterial(std::string file)
 	{
 	{
 
 
 		objl::Loader loader;
 		objl::Loader loader;
@@ -36686,7 +36782,7 @@ namespace gl3d
 	}
 	}
 
 
 	PBRTexture Renderer3D::createPBRTexture(Texture& roughness, Texture& metallic,
 	PBRTexture Renderer3D::createPBRTexture(Texture& roughness, Texture& metallic,
-		Texture& ambientOcclusion, GLuint frameBuffer)
+		Texture& ambientOcclusion)
 	{
 	{
 
 
 		PBRTexture ret = {};
 		PBRTexture ret = {};
@@ -36708,7 +36804,7 @@ namespace gl3d
 		t.RMA_loadedTextures = 0;
 		t.RMA_loadedTextures = 0;
 	}
 	}
 
 
-	Model Renderer3D::loadModel(std::string path, GLuint frameBuffer, float scale)
+	Model Renderer3D::loadModel(std::string path, float scale)
 	{
 	{
 
 
 		gl3d::LoadedModelData model(path.c_str(), errorReporter, fileOpener, scale);
 		gl3d::LoadedModelData model(path.c_str(), errorReporter, fileOpener, scale);
@@ -36800,7 +36896,7 @@ namespace gl3d
 				}else
 				}else
 				{
 				{
 					//if no material loaded for this object create a new default one
 					//if no material loaded for this object create a new default one
-					gm.material = createMaterial(frameBuffer, glm::vec4{ 0.8f,0.8f,0.8f, 1.0f }, 0.5f, 0.f, 1.f, "default material");
+					gm.material = createMaterial(glm::vec4{ 0.8f,0.8f,0.8f, 1.0f }, 0.5f, 0.f, 1.f, "default material");
 				}
 				}
 				
 				
 				gm.ownMaterial = true;
 				gm.ownMaterial = true;
@@ -37551,7 +37647,7 @@ namespace gl3d
 		return e;
 		return e;
 	}
 	}
 
 
-	Entity Renderer3D::duplicateEntity(Entity& e, GLuint frameBuffer)
+	Entity Renderer3D::duplicateEntity(Entity& e)
 	{
 	{
 		int oldIndex = internal.getEntityIndex(e);
 		int oldIndex = internal.getEntityIndex(e);
 
 
@@ -37792,7 +37888,7 @@ namespace gl3d
 
 
 	}
 	}
 
 
-	void Renderer3D::setEntityMeshMaterialValues(Entity& e, int meshIndex, MaterialValues mat, GLuint frameBuffer)
+	void Renderer3D::setEntityMeshMaterialValues(Entity& e, int meshIndex, MaterialValues mat)
 	{
 	{
 		auto i = internal.getEntityIndex(e);
 		auto i = internal.getEntityIndex(e);
 		if (i < 0) { return ; } //warn or sthing
 		if (i < 0) { return ; } //warn or sthing
@@ -37813,7 +37909,7 @@ namespace gl3d
 				}else
 				}else
 				if (mat != data)
 				if (mat != data)
 				{
 				{
-					Material newMat = this->createMaterial(frameBuffer, mat.kd, mat.roughness,
+					Material newMat = this->createMaterial(mat.kd, mat.roughness,
 						mat.metallic, mat.ao, name);
 						mat.metallic, mat.ao, name);
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 
 
@@ -37861,7 +37957,7 @@ namespace gl3d
 
 
 	}
 	}
 
 
-	void Renderer3D::setEntityMeshMaterialName(Entity& e, int meshIndex, const std::string& name, GLuint frameBuffer)
+	void Renderer3D::setEntityMeshMaterialName(Entity& e, int meshIndex, const std::string& name)
 	{
 	{
 		auto i = internal.getEntityIndex(e);
 		auto i = internal.getEntityIndex(e);
 		if (i < 0) { return; } //warn or sthing
 		if (i < 0) { return; } //warn or sthing
@@ -37883,7 +37979,7 @@ namespace gl3d
 				else
 				else
 				if (name != oldName) //copy to new material
 				if (name != oldName) //copy to new material
 				{
 				{
-					Material newMat = this->createMaterial(frameBuffer, data.kd, data.roughness,
+					Material newMat = this->createMaterial(data.kd, data.roughness,
 						data.metallic, data.ao, name);
 						data.metallic, data.ao, name);
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 					internal.materialTexturesData[newMatIndex] = textures;
 					internal.materialTexturesData[newMatIndex] = textures;
@@ -37956,7 +38052,7 @@ namespace gl3d
 		}
 		}
 	}
 	}
 
 
-	void Renderer3D::setEntityMeshMaterialTextures(Entity& e, int meshIndex, TextureDataForMaterial texture, GLuint frameBuffer)
+	void Renderer3D::setEntityMeshMaterialTextures(Entity& e, int meshIndex, TextureDataForMaterial texture)
 	{
 	{
 		auto i = internal.getEntityIndex(e);
 		auto i = internal.getEntityIndex(e);
 		if (i < 0) { return; } //warn or sthing
 		if (i < 0) { return; } //warn or sthing
@@ -37978,7 +38074,7 @@ namespace gl3d
 				else
 				else
 				if (texture != oldTextures) //copy to new material
 				if (texture != oldTextures) //copy to new material
 				{
 				{
-					Material newMat = this->createMaterial(frameBuffer, data.kd, data.roughness,
+					Material newMat = this->createMaterial(data.kd, data.roughness,
 						data.metallic, data.ao, oldName);
 						data.metallic, data.ao, oldName);
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 					int newMatIndex = internal.getMaterialIndex(newMat); //this should not fail
 					internal.materialTexturesData[newMatIndex] = texture; //new textures
 					internal.materialTexturesData[newMatIndex] = texture; //new textures
@@ -38882,10 +38978,10 @@ namespace gl3d
 	};
 	};
 
 
 
 
-	void Renderer3D::render(float deltaTime, GLuint frameBuffer)
+	void Renderer3D::render(float deltaTime)
 	{
 	{
 	
 	
-		if (internal.w == 0 || internal.h == 0)
+		if (internal.w <= 0 || internal.h <= 0)
 		{
 		{
 			return;
 			return;
 		}
 		}
@@ -40031,9 +40127,16 @@ namespace gl3d
 
 
 		#pragma endregion
 		#pragma endregion
 
 
-
-		glBindFramebuffer(GL_FRAMEBUFFER, internal.gBuffer.gBuffer);
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		#pragma region clear gbuffer
+		{
+			glBindFramebuffer(GL_FRAMEBUFFER, internal.gBuffer.gBuffer);
+			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		
+			float clearPositionColor[4] = {0,0,-INFINITY, 0};
+			glClearBufferfv(GL_COLOR, internal.gBuffer.positionViewSpace, clearPositionColor);
+		}
+		#pragma endregion
+	
 		glViewport(0, 0, internal.adaptiveW, internal.adaptiveH);
 		glViewport(0, 0, internal.adaptiveW, internal.adaptiveH);
 
 
 
 
@@ -40236,7 +40339,7 @@ namespace gl3d
 				for (auto& i : entity.models)
 				for (auto& i : entity.models)
 				{
 				{
 					
 					
-					if (frustumCulling && i.culledThisFrame)
+					if (frustumCulling && i.culledThisFrame) //todo data oriented design, move not culled objects to a new buffer
 					{
 					{
 						continue;
 						continue;
 					}
 					}
@@ -40508,54 +40611,105 @@ namespace gl3d
 
 
 		if (internal.lightShader.useSSAO)
 		if (internal.lightShader.useSSAO)
 		{
 		{
-			glViewport(0, 0, internal.adaptiveW / 2, internal.adaptiveH / 2);
 
 
-			glUseProgram(internal.ssao.shader.id);
+			if (1)
+			{
+				//ssao
 
 
-			//todo lazyness
-			glBindBuffer(GL_UNIFORM_BUFFER, internal.ssao.ssaoUniformBlockBuffer);
-			glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(InternalStruct::SSAO::SsaoShaderUniformBlockData),
-				&internal.ssao.ssaoShaderUniformBlockData);
+				glViewport(0, 0, internal.adaptiveW / 2, internal.adaptiveH / 2);
 
 
-			glUniformMatrix4fv(internal.ssao.u_projection, 1, GL_FALSE,
-				&(camera.getProjectionMatrix())[0][0]);
+				glUseProgram(internal.ssao.shader.id);
 
 
-			glUniformMatrix4fv(internal.ssao.u_view, 1, GL_FALSE,
-				&(camera.getWorldToViewMatrix())[0][0]);
+				//todo lazyness
+				glBindBuffer(GL_UNIFORM_BUFFER, internal.ssao.ssaoUniformBlockBuffer);
+				glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(InternalStruct::SSAO::SsaoShaderUniformBlockData),
+					&internal.ssao.ssaoShaderUniformBlockData);
 
 
-			glUniform3fv(internal.ssao.u_samples, 64, &(internal.ssao.ssaoKernel[0][0]));
+				glUniformMatrix4fv(internal.ssao.u_projection, 1, GL_FALSE,
+					&(camera.getProjectionMatrix())[0][0]);
 
 
-			glBindFramebuffer(GL_FRAMEBUFFER, internal.ssao.ssaoFBO);
-			glClear(GL_COLOR_BUFFER_BIT);
+				glUniformMatrix4fv(internal.ssao.u_view, 1, GL_FALSE,
+					&(camera.getWorldToViewMatrix())[0][0]);
 
 
-			glActiveTexture(GL_TEXTURE0);
-			glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.positionViewSpace]);
-			glUniform1i(internal.ssao.u_gPosition, 0);
+				glUniform3fv(internal.ssao.u_samples, 64, &(internal.ssao.ssaoKernel[0][0]));
 
 
-			glActiveTexture(GL_TEXTURE1);
-			glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.normal]);
-			glUniform1i(internal.ssao.u_gNormal, 1);
 
 
-			glActiveTexture(GL_TEXTURE2);
-			glBindTexture(GL_TEXTURE_2D, internal.ssao.noiseTexture);
-			glUniform1i(internal.ssao.u_texNoise, 2);
+				glUniform1f(internal.ssao.u_aspectRatio, camera.aspectRatio);
+				glUniform1f(internal.ssao.u_tanHalfFOV, std::tan(camera.fovRadians/2.f));
+				
+				glUniform1f(internal.ssao.u_farPlane, camera.farPlane);
+				glUniform1f(internal.ssao.u_closePlane, camera.closePlane);
+				
 
 
-			glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+				glBindFramebuffer(GL_FRAMEBUFFER, internal.ssao.ssaoFBO);
+				glClear(GL_COLOR_BUFFER_BIT);
 
 
+				glActiveTexture(GL_TEXTURE0);
+				glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.positionViewSpace]);
+				glUniform1i(internal.ssao.u_gPosition, 0);
 
 
-		#pragma region ssao "blur" (more like average blur)
-			glViewport(0, 0, internal.adaptiveW / 4, internal.adaptiveH / 4);
+				glActiveTexture(GL_TEXTURE1);
+				glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.normal]);
+				glUniform1i(internal.ssao.u_gNormal, 1);
 
 
-			glBindFramebuffer(GL_FRAMEBUFFER, internal.ssao.blurBuffer);
-			internal.ssao.blurShader.bind();
-			glClear(GL_COLOR_BUFFER_BIT);
-			glActiveTexture(GL_TEXTURE0);
-			glBindTexture(GL_TEXTURE_2D, internal.ssao.ssaoColorBuffer);
-			glUniform1i(internal.ssao.u_ssaoInput, 0);
-			glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+				glActiveTexture(GL_TEXTURE2);
+				glBindTexture(GL_TEXTURE_2D, internal.ssao.noiseTexture);
+				glUniform1i(internal.ssao.u_texNoise, 2);
 
 
-			glViewport(0, 0, internal.adaptiveW, internal.adaptiveH);
+				glActiveTexture(GL_TEXTURE3);
+				glBindTexture(GL_TEXTURE_2D, internal.gBuffer.depthBuffer);
+				glUniform1i(internal.ssao.u_depthBuffer, 3);
+
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+			}
+			else
+			{
+				//hbao
+				glViewport(0, 0, internal.adaptiveW / 2, internal.adaptiveH / 2);
+				glUseProgram(internal.hbao.shader.id);
+
+				glUniformMatrix4fv(internal.hbao.u_projection, 1, GL_FALSE,
+					&(camera.getProjectionMatrix())[0][0]);
+				glUniformMatrix4fv(internal.hbao.u_view, 1, GL_FALSE,
+					&(camera.getWorldToViewMatrix())[0][0]);
+
+				glBindFramebuffer(GL_FRAMEBUFFER, internal.ssao.ssaoFBO);
+				glClear(GL_COLOR_BUFFER_BIT);
+
+				glActiveTexture(GL_TEXTURE0);
+				glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.positionViewSpace]);
+				glUniform1i(internal.hbao.u_gPosition, 0);
+
+				glActiveTexture(GL_TEXTURE1);
+				glBindTexture(GL_TEXTURE_2D, internal.gBuffer.buffers[internal.gBuffer.normal]);
+				glUniform1i(internal.hbao.u_gNormal, 1);
+
+				glActiveTexture(GL_TEXTURE2);
+				glBindTexture(GL_TEXTURE_2D, internal.ssao.noiseTexture);
+				glUniform1i(internal.hbao.u_texNoise, 2);
+
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+
+			}
+
+
+		#pragma region ssao/hbao "blur" (more like average blur)
+				glViewport(0, 0, internal.adaptiveW / 4, internal.adaptiveH / 4);
+
+				glBindFramebuffer(GL_FRAMEBUFFER, internal.ssao.blurBuffer);
+				internal.ssao.blurShader.bind();
+				glClear(GL_COLOR_BUFFER_BIT);
+				glActiveTexture(GL_TEXTURE0);
+				glBindTexture(GL_TEXTURE_2D, internal.ssao.ssaoColorBuffer);
+				glUniform1i(internal.ssao.u_ssaoInput, 0);
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 		#pragma endregion
 		#pragma endregion
+
+
+			glViewport(0, 0, internal.adaptiveW, internal.adaptiveH);
+
 		}
 		}
 	#pragma endregion
 	#pragma endregion
 
 
@@ -40983,7 +41137,7 @@ namespace gl3d
 		//gbuffer
 		//gbuffer
 		internal.gBuffer.resize(internal.adaptiveW, internal.adaptiveH);
 		internal.gBuffer.resize(internal.adaptiveW, internal.adaptiveH);
 
 
-		//ssao
+		//ssao and hbao
 		internal.ssao.resize(internal.adaptiveW, internal.adaptiveH);
 		internal.ssao.resize(internal.adaptiveW, internal.adaptiveH);
 	
 	
 		//bloom buffer and color buffer
 		//bloom buffer and color buffer
@@ -41024,7 +41178,7 @@ namespace gl3d
 
 
 	}
 	}
 
 
-	SkyBox Renderer3D::loadSkyBox(const char *names[6], GLuint frameBuffer)
+	SkyBox Renderer3D::loadSkyBox(const char *names[6])
 	{
 	{
 		SkyBox skyBox = {};
 		SkyBox skyBox = {};
 		internal.skyBoxLoaderAndDrawer.loadTexture(names, skyBox, errorReporter, fileOpener, frameBuffer);
 		internal.skyBoxLoaderAndDrawer.loadTexture(names, skyBox, errorReporter, fileOpener, frameBuffer);
@@ -41038,7 +41192,7 @@ namespace gl3d
 		return skyBox;
 		return skyBox;
 	}
 	}
 
 
-	SkyBox Renderer3D::loadHDRSkyBox(const char *name, GLuint frameBuffer)
+	SkyBox Renderer3D::loadHDRSkyBox(const char *name)
 	{
 	{
 		SkyBox skyBox = {};
 		SkyBox skyBox = {};
 		internal.skyBoxLoaderAndDrawer.loadHDRtexture(name, errorReporter, fileOpener, skyBox, frameBuffer);
 		internal.skyBoxLoaderAndDrawer.loadHDRtexture(name, errorReporter, fileOpener, skyBox, frameBuffer);
@@ -41050,7 +41204,7 @@ namespace gl3d
 		skyBox.clearTextures();
 		skyBox.clearTextures();
 	}
 	}
 
 
-	SkyBox Renderer3D::atmosfericScattering(glm::vec3 sun, glm::vec3 color1, glm::vec3 color2, float g, GLuint frameBuffer)
+	SkyBox Renderer3D::atmosfericScattering(glm::vec3 sun, glm::vec3 color1, glm::vec3 color2, float g)
 	{
 	{
 		SkyBox skyBox = {};
 		SkyBox skyBox = {};
 		internal.skyBoxLoaderAndDrawer.atmosphericScattering(sun, color1, color2, g, skyBox, frameBuffer);
 		internal.skyBoxLoaderAndDrawer.atmosphericScattering(sun, color1, color2, g, skyBox, frameBuffer);
@@ -41132,7 +41286,13 @@ namespace gl3d
 		u_gNormal = getUniform(shader.id, "u_gNormal", errorReporter);
 		u_gNormal = getUniform(shader.id, "u_gNormal", errorReporter);
 		u_texNoise = getUniform(shader.id, "u_texNoise", errorReporter);
 		u_texNoise = getUniform(shader.id, "u_texNoise", errorReporter);
 		u_samples = getUniform(shader.id, "samples[0]", errorReporter);
 		u_samples = getUniform(shader.id, "samples[0]", errorReporter);
-		
+		u_depthBuffer = getUniform(shader.id, "u_depthBuffer", errorReporter);
+		u_aspectRatio = getUniform(shader.id, "u_aspectRatio", errorReporter);
+		u_tanHalfFOV = getUniform(shader.id, "u_tanHalfFOV", errorReporter);
+		u_farPlane = getUniform(shader.id, "u_farPlane", errorReporter);
+		u_closePlane = getUniform(shader.id, "u_closePlane", errorReporter);
+
+
 
 
 		glGenBuffers(1, &ssaoUniformBlockBuffer);
 		glGenBuffers(1, &ssaoUniformBlockBuffer);
 		glBindBuffer(GL_UNIFORM_BUFFER, ssaoUniformBlockBuffer);
 		glBindBuffer(GL_UNIFORM_BUFFER, ssaoUniformBlockBuffer);
@@ -41883,6 +42043,20 @@ namespace gl3d
 		}
 		}
 	}
 	}
 
 
+	void Renderer3D::InternalStruct::HBAO::create(ErrorReporter &errorReporter, FileOpener &fileOpener, GLuint frameBuffer)
+	{
+
+		shader.loadShaderProgramFromFile("shaders/drawQuads.vert", "shaders/hbao/hbao.frag", errorReporter, fileOpener);
+
+		u_projection = getUniform(shader.id, "u_projection", errorReporter);
+		u_view = getUniform(shader.id, "u_view", errorReporter);
+		u_gPosition = getUniform(shader.id, "u_gPosition", errorReporter);
+		u_gNormal = getUniform(shader.id, "u_gNormal", errorReporter);
+		u_texNoise = getUniform(shader.id, "u_texNoise", errorReporter);
+		
+	}
+
+
 };
 };
 #pragma endregion
 #pragma endregion
 
 

+ 69 - 46
Pika/thirdparty/gl3d/gl3d.h

@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 //gl32 --Vlad Luta -- 
 //gl32 --Vlad Luta -- 
-//built on 2022-11-22
+//built on 2023-01-23
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 
 
 
 
@@ -34321,7 +34321,7 @@ namespace gl3d
 		unsigned char flags = {}; // lsb -> 1 static, visible, shadows
 		unsigned char flags = {}; // lsb -> 1 static, visible, shadows
 
 
 		GL3D_ADD_FLAG(isStatic, setStatic, 0);
 		GL3D_ADD_FLAG(isStatic, setStatic, 0);
-		GL3D_ADD_FLAG(isVisible, setVisible, 1);
+		GL3D_ADD_FLAG(isVisible, setVisible, 1); //set by user
 		GL3D_ADD_FLAG(castShadows, setCastShadows, 2);
 		GL3D_ADD_FLAG(castShadows, setCastShadows, 2);
 		GL3D_ADD_FLAG(animate, setAnimate, 3);
 		GL3D_ADD_FLAG(animate, setAnimate, 3);
 
 
@@ -34353,7 +34353,7 @@ namespace gl3d
 		GLuint vertexBuffer = 0;
 		GLuint vertexBuffer = 0;
 		GLuint captureFBO;
 		GLuint captureFBO;
 
 
-		void createGpuData(ErrorReporter &errorReporter, FileOpener &fileOpener,  GLuint frameBuffer);
+		void createGpuData(ErrorReporter &errorReporter, FileOpener &fileOpener, GLuint frameBuffer);
 
 
 		struct
 		struct
 		{
 		{
@@ -34510,8 +34510,10 @@ namespace gl3d
 	{
 	{
 		//todo store the default fbo
 		//todo store the default fbo
 		//size of the screen and the default frameBuffer
 		//size of the screen and the default frameBuffer
-		void init(int x, int y, GLuint frameBuffer, const char *BRDFIntegrationMapFileLocation);
+		void init(int x, int y, const char *BRDFIntegrationMapFileLocation, GLuint frameBuffer = 0);
 		
 		
+		GLuint frameBuffer = 0;
+
 		ErrorReporter errorReporter;
 		ErrorReporter errorReporter;
 		FileOpener fileOpener;
 		FileOpener fileOpener;
 
 
@@ -34520,14 +34522,14 @@ namespace gl3d
 
 
 	#pragma region material
 	#pragma region material
 		
 		
-		Material createMaterial(GLuint frameBuffer, glm::vec4 kd = glm::vec4(1), 
+		Material createMaterial(glm::vec4 kd = glm::vec4(1), 
 			float roughness = 0.5f, float metallic = 0.1, float ao = 1.f, std::string name = "",
 			float roughness = 0.5f, float metallic = 0.1, float ao = 1.f, std::string name = "",
 			gl3d::Texture albedoTexture = {}, gl3d::Texture normalTexture = {}, gl3d::Texture roughnessTexture = {}, gl3d::Texture metallicTexture = {},
 			gl3d::Texture albedoTexture = {}, gl3d::Texture normalTexture = {}, gl3d::Texture roughnessTexture = {}, gl3d::Texture metallicTexture = {},
 			gl3d::Texture occlusionTexture = {}, gl3d::Texture emmisiveTexture = {});
 			gl3d::Texture occlusionTexture = {}, gl3d::Texture emmisiveTexture = {});
 
 
-		Material createMaterial(Material m, GLuint frameBuffer);
+		Material createMaterial(Material m);
 
 
-		std::vector<Material> loadMaterial(std::string file,  GLuint frameBuffer);
+		std::vector<Material> loadMaterial(std::string file);
 
 
 		bool deleteMaterial(Material m);  
 		bool deleteMaterial(Material m);  
 		bool copyMaterialData(Material dest, Material source);
 		bool copyMaterialData(Material dest, Material source);
@@ -34564,19 +34566,19 @@ namespace gl3d
 		Texture createIntenralTexture(GLuint id_, int alphaData, int alphaValues, const std::string &name = "");
 		Texture createIntenralTexture(GLuint id_, int alphaData, int alphaValues, const std::string &name = "");
 
 
 		PBRTexture createPBRTexture(Texture& roughness, Texture& metallic,
 		PBRTexture createPBRTexture(Texture& roughness, Texture& metallic,
-			Texture& ambientOcclusion, GLuint frameBuffer);
+			Texture& ambientOcclusion);
 		void deletePBRTexture(PBRTexture &t);
 		void deletePBRTexture(PBRTexture &t);
 
 
 	#pragma endregion
 	#pragma endregion
 
 
 	#pragma region skyBox
 	#pragma region skyBox
 
 
-		SkyBox loadSkyBox(const char* names[6], GLuint frameBuffer);
+		SkyBox loadSkyBox(const char* names[6]);
 		SkyBox loadSkyBox(const char* name, int format = 0);
 		SkyBox loadSkyBox(const char* name, int format = 0);
-		SkyBox loadHDRSkyBox(const char* name, GLuint frameBuffer);
+		SkyBox loadHDRSkyBox(const char* name);
 		void deleteSkyBoxTextures(SkyBox& skyBox);
 		void deleteSkyBoxTextures(SkyBox& skyBox);
 
 
-		SkyBox atmosfericScattering(glm::vec3 sun, glm::vec3 color1, glm::vec3 color2, float g, GLuint frameBuffer);
+		SkyBox atmosfericScattering(glm::vec3 sun, glm::vec3 color1, glm::vec3 color2, float g);
 
 
 	#pragma endregion
 	#pragma endregion
 
 
@@ -34584,7 +34586,7 @@ namespace gl3d
 
 
 		//todo implement stuff here
 		//todo implement stuff here
 
 
-		Model loadModel(std::string path, GLuint frameBuffer, float scale = 1);
+		Model loadModel(std::string path, float scale = 1);
 		bool isModel(Model& m);
 		bool isModel(Model& m);
 		void deleteModel(Model &m);
 		void deleteModel(Model &m);
 
 
@@ -34684,7 +34686,7 @@ namespace gl3d
 		Entity createEntity(Model m, Transform transform = {}, 
 		Entity createEntity(Model m, Transform transform = {}, 
 			bool staticGeometry = 1, bool visible = 1, bool castShadows = 1);
 			bool staticGeometry = 1, bool visible = 1, bool castShadows = 1);
 
 
-		Entity duplicateEntity(Entity &e, GLuint frameBuffer);
+		Entity duplicateEntity(Entity &e);
 
 
 		void setEntityModel(Entity& e, Model m);
 		void setEntityModel(Entity& e, Model m);
 		void clearEntityModel(Entity& e);
 		void clearEntityModel(Entity& e);
@@ -34722,15 +34724,15 @@ namespace gl3d
 
 
 		int getEntityMeshesCount(Entity& e);
 		int getEntityMeshesCount(Entity& e);
 		MaterialValues getEntityMeshMaterialValues(Entity& e, int meshIndex);
 		MaterialValues getEntityMeshMaterialValues(Entity& e, int meshIndex);
-		void setEntityMeshMaterialValues(Entity& e, int meshIndex, MaterialValues mat, GLuint frameBuffer);
+		void setEntityMeshMaterialValues(Entity& e, int meshIndex, MaterialValues mat);
 
 
 		std::string getEntityMeshMaterialName(Entity& e, int meshIndex);
 		std::string getEntityMeshMaterialName(Entity& e, int meshIndex);
-		void setEntityMeshMaterialName(Entity& e, int meshIndex, const std::string &name, GLuint frameBuffer);
+		void setEntityMeshMaterialName(Entity& e, int meshIndex, const std::string &name);
 		
 		
 		void setEntityMeshMaterial(Entity& e, int meshIndex, Material mat);
 		void setEntityMeshMaterial(Entity& e, int meshIndex, Material mat);
 		
 		
 		TextureDataForMaterial getEntityMeshMaterialTextures(Entity& e, int meshIndex);
 		TextureDataForMaterial getEntityMeshMaterialTextures(Entity& e, int meshIndex);
-		void setEntityMeshMaterialTextures(Entity& e, int meshIndex, TextureDataForMaterial texture, GLuint frameBuffer);
+		void setEntityMeshMaterialTextures(Entity& e, int meshIndex, TextureDataForMaterial texture);
 
 
 	#pragma endregion
 	#pragma endregion
 
 
@@ -34929,46 +34931,67 @@ namespace gl3d
 			}showNormalsProgram;
 			}showNormalsProgram;
 
 
 			struct SSAO
 			struct SSAO
+			{
+				//https://learnopengl.com/Advanced-Lighting/SSAO
+
+				void create(int w, int h, ErrorReporter &errorReporter, FileOpener &fileOpener, GLuint frameBuffer);
+				void resize(int w, int h);
+
+				glm::ivec2 currentDimensions = {};
+
+				GLuint noiseTexture;
+				GLuint ssaoFBO;
+				GLuint ssaoColorBuffer;
+
+				Shader shader;
+
+				GLuint ssaoUniformBlockBuffer;
+				struct SsaoShaderUniformBlockData
 				{
 				{
-					//https://learnopengl.com/Advanced-Lighting/SSAO
+					float radius = 0.2;
+					float bias = 0.025;
+					int samplesTestSize = 16; // should be less than kernelSize (64)
 
 
-					void create(int w, int h, ErrorReporter &errorReporter, FileOpener &fileOpener, GLuint frameBuffer);
-					void resize(int w, int h);
+				}ssaoShaderUniformBlockData;
 
 
-					glm::ivec2 currentDimensions = {};
+				GLint u_projection = -1;
+				GLint u_view = -1;
+				GLint u_gPosition = -1;
+				GLint u_gNormal = -1;
+				GLint u_texNoise = -1;
+				GLint u_samples = -1;
+				GLuint u_SSAODATA;
+				GLint u_depthBuffer = -1;
+				GLint u_aspectRatio = -1;
+				GLint u_tanHalfFOV = -1;
+				GLint u_farPlane = -1;
+				GLint u_closePlane = -1;
 
 
-					GLuint noiseTexture;
-					GLuint ssaoFBO;
-					GLuint ssaoColorBuffer;
 
 
-					Shader shader;
+				std::vector<glm::vec3> ssaoKernel;
 
 
-					GLuint ssaoUniformBlockBuffer;
-					struct SsaoShaderUniformBlockData
-					{
-						float radius = 0.2;
-						float bias = 0.025;
-						int samplesTestSize = 16; // should be less than kernelSize (64)
+				GLuint blurBuffer;
+				GLuint blurColorBuffer;
+				GLint u_ssaoInput;
+				Shader blurShader;
 
 
-					}ssaoShaderUniformBlockData;
+				float ssao_finalColor_exponent = 5.f;
+			}ssao;
 
 
-					GLint u_projection = -1;
-					GLint u_view = -1;
-					GLint u_gPosition = -1;
-					GLint u_gNormal = -1;
-					GLint u_texNoise = -1;
-					GLint u_samples = -1;
-					GLuint u_SSAODATA;
+			struct HBAO
+			{
+				//https://developer.download.nvidia.com/presentations/2008/SIGGRAPH/HBAO_SIG08b.pdf
 
 
-					std::vector<glm::vec3> ssaoKernel;
+				void create(ErrorReporter &errorReporter, FileOpener &fileOpener, GLuint frameBuffer);
+				Shader shader;
 
 
-					GLuint blurBuffer;
-					GLuint blurColorBuffer;
-					GLint u_ssaoInput;
-					Shader blurShader;
+				GLint u_projection = -1;
+				GLint u_view = -1;
+				GLint u_gPosition = -1;
+				GLint u_gNormal = -1;
+				GLint u_texNoise = -1;
 
 
-					float ssao_finalColor_exponent = 5.f;
-				}ssao;
+			}hbao;
 
 
 			struct GBuffer
 			struct GBuffer
 			{
 			{
@@ -35201,7 +35224,7 @@ namespace gl3d
 		}renderDepthMap;
 		}renderDepthMap;
 		void renderADepthMap(GLuint texture, GLuint frameBuffer);
 		void renderADepthMap(GLuint texture, GLuint frameBuffer);
 
 
-		void render(float deltaTime, GLuint frameBuffer = 0);
+		void render(float deltaTime);
 		void updateWindowMetrics(int x, int y);
 		void updateWindowMetrics(int x, int y);
 
 
 		bool frustumCulling = 1;
 		bool frustumCulling = 1;

Some files were not shown because too many files changed in this diff