diff --git a/CMakeSettings.json b/CMakeSettings.json index 074fbf0..38f2e2c 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -26,7 +26,7 @@ }, { "name": "RelWithDebInfo", - "generator": "Ninja Multi-Config", + "generator": "Ninja", "configurationType": "RelWithDebInfo", "buildRoot": "${workspaceRoot}/build", "installRoot": "C:/Program Files/Seele", diff --git a/MinecraftClone/Assets/arial.asset b/MinecraftClone/Assets/arial.asset new file mode 100644 index 0000000..2a8a2bd Binary files /dev/null and b/MinecraftClone/Assets/arial.asset differ diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 2e425cf..a527235 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -24,54 +24,11 @@ using namespace Seele::Editor; // make it global so it gets deleted last and automatically static Gfx::OGraphics graphics; -struct Halfedge { - uint32 vertexID; - uint32 nextID; - uint32 prevID; - uint32 twinID; -}; -Array generateEdges() { - Array indices = {UVector(0, 1, 4), UVector(4, 1, 5), UVector(1, 2, 5), UVector(5, 2, 6), UVector(2, 3, 6), - UVector(6, 3, 7), UVector(4, 5, 8), UVector(8, 5, 9), UVector(5, 6, 9), UVector(9, 6, 10), - UVector(6, 7, 10), UVector(10, 7, 11), UVector(8, 9, 12), UVector(12, 9, 13), UVector(9, 10, 13), - UVector(13, 10, 14), UVector(10, 11, 14), UVector(14, 11, 15)}; - Array edges; - for (auto ind : indices) { - uint32 baseIndex = (uint32)edges.size(); - edges.add(Halfedge{ind.x, baseIndex + 1, baseIndex + 2, UINT32_MAX}); - edges.add(Halfedge{ind.y, baseIndex + 2, baseIndex, UINT32_MAX}); - edges.add(Halfedge{ind.z, baseIndex, baseIndex + 1, UINT32_MAX}); - } - for (uint32 i = 0; i < edges.size(); ++i) { - if (edges[i].twinID == UINT32_MAX) { - for (uint32 j = 0; j < edges.size(); ++j) { - if (edges[i].vertexID == edges[edges[j].nextID].vertexID && edges[edges[i].nextID].vertexID == edges[j].vertexID) { - edges[i].twinID = j; - edges[j].twinID = i; - } - } - } - } - return edges; -} - -Array generateArray() { return Array(); } - int main() { - std::string gameName = "MeshShadingDemo"; -#ifdef WIN32 - std::filesystem::path outputPath = "C:/Users/Dynamitos/MeshShadingDemoGame"; - std::filesystem::path sourcePath = "C:/Users/Dynamitos/MeshShadingDemo"; - std::filesystem::path binaryPath = sourcePath / "bin" / "MeshShadingDemo.dll"; -#elif __APPLE__ - std::filesystem::path outputPath = "/Users/dynamitos/MeshShadingDemoGame"; - std::filesystem::path sourcePath = "/Users/dynamitos/MeshShadingDemo"; - std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.dylib"; -#else - std::filesystem::path outputPath = "/home/dynamitos/MeshShadingDemoGame"; - std::filesystem::path sourcePath = "/home/dynamitos/MeshShadingDemo"; - std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.so"; -#endif + std::string gameName = "MinecraftClone"; + std::filesystem::path outputPath = fmt::format("../../{0}Game", gameName); + std::filesystem::path sourcePath = fmt::format("../../{0}", gameName); + std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{0}.dll", gameName); std::filesystem::path cmakePath = outputPath / "cmake"; if (true) { #ifdef __APPLE__ @@ -90,55 +47,10 @@ int main() { AssetImporter::importFont(FontImportArgs{ .filePath = "./fonts/arial.ttf", }); - AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "import/models/cube.fbx", - }); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/culling.fbx", - //}); - AssetImporter::importTexture(TextureImportArgs{ - .filePath = sourcePath / "import/textures/skybox.jpg", - .type = TextureImportType::TEXTURE_CUBEMAP, - }); - //AssetImporter::importEnvironmentMap(EnvironmentImportArgs{ - // .filePath = sourcePath / "import/models/main1_sponza/textures/kloppenheim_05_4k.hdr", - //}); AssetImporter::importEnvironmentMap(EnvironmentImportArgs{ - .filePath = sourcePath / "import/textures/newport_loft.hdr", + .filePath = sourcePath / "import" / "textures" / "newport_loft.hdr", }); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/ship.fbx", - // .importPath = "ship", - // }); - // AssetImporter::importTexture(TextureImportArgs{ - // .filePath = sourcePath / "import/textures/azeroth.png", - //}); - // AssetImporter::importTexture(TextureImportArgs{ - // .filePath = sourcePath / "import/textures/azeroth_height.png", - //}); - // AssetImporter::importTexture(TextureImportArgs{ - // .filePath = sourcePath / "import/textures/wgen.png", - //}); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb", - // .importPath = "Whitechapel", - //}); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/box.glb", - // .importPath = "", - //}); - AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "import/models/rttest.glb", - .importPath = "", - }); - AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "import/models/main1_sponza/sponza.gltf", - .importPath = "sponza", - }); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/town_hall.glb", - // .importPath = "", - // }); + getThreadPool().waitIdle(); vd->commitMeshes(); WindowCreateInfo mainWindowInfo = { diff --git a/src/Engine/Asset/AssetRegistry.cpp b/src/Engine/Asset/AssetRegistry.cpp index 7535d13..1dc9714 100644 --- a/src/Engine/Asset/AssetRegistry.cpp +++ b/src/Engine/Asset/AssetRegistry.cpp @@ -224,6 +224,14 @@ void AssetRegistry::initialize(const std::filesystem::path& _rootFolder, Gfx::PG this->graphics = _graphics; this->rootFolder = _rootFolder; this->assetRoot = new AssetFolder(""); + if (!std::filesystem::exists(rootFolder)) + { + std::filesystem::create_directories(rootFolder); + } + else if (!std::filesystem::is_directory(rootFolder)) + { + throw std::logic_error("Asset Folder is not a directory!!"); + } loadRegistryInternal(); } diff --git a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp index 01eb342..c2587c8 100644 --- a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp +++ b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp @@ -1,6 +1,7 @@ #include "RayTracingPass.h" #include "Asset/AssetRegistry.h" #include "Asset/MeshAsset.h" +#include "Asset/EnvironmentMapAsset.h" #include "Graphics/Mesh.h" #include "Graphics/RayTracing.h" #include "Graphics/Shader.h" @@ -59,7 +60,7 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa .useMaterial = true, .rayTracing = true, }); - skyBox = AssetRegistry::findTexture("", "skybox")->getTexture().cast(); + skyBox = AssetRegistry::findEnvironmentMap("", "newport_loft")->getIrradianceMap(); skyBoxSampler = graphics->createSampler({}); } diff --git a/src/Engine/Graphics/Vulkan/Buffer.cpp b/src/Engine/Graphics/Vulkan/Buffer.cpp index b71fe8e..deaaf94 100644 --- a/src/Engine/Graphics/Vulkan/Buffer.cpp +++ b/src/Engine/Graphics/Vulkan/Buffer.cpp @@ -11,6 +11,8 @@ using namespace Seele::Vulkan; BufferAllocation::BufferAllocation(PGraphics graphics, const std::string& name, VkBufferCreateInfo bufferInfo, VmaAllocationCreateInfo allocInfo, Gfx::QueueType owner, uint64 alignment) : CommandBoundResource(graphics, name), size(bufferInfo.size), owner(owner) { + if (bufferInfo.size == 0) + return; VK_CHECK(vmaCreateBufferWithAlignment(graphics->getAllocator(), &bufferInfo, &allocInfo, alignment, &buffer, &allocation, &info)); vmaGetAllocationMemoryProperties(graphics->getAllocator(), allocation, &properties); assert(!name.empty()); @@ -437,6 +439,8 @@ void* ShaderBuffer::map() { return Vulkan::Buffer::map(); } void ShaderBuffer::unmap() { Vulkan::Buffer::unmap(); } void ShaderBuffer::clear() { + if (getAlloc() == nullptr) + return; PCommand command = graphics->getQueueCommands(getAlloc()->owner)->getCommands(); command->bindResource(PBufferAllocation(getAlloc())); vkCmdFillBuffer(command->getHandle(), Vulkan::Buffer::getHandle(), 0, VK_WHOLE_SIZE, 0); diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index a1441ed..a3a0006 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -447,7 +447,7 @@ Gfx::OTopLevelAS Graphics::createTopLevelAccelerationStructure(const Gfx::TopLev } void Graphics::buildBottomLevelAccelerationStructures(Array data) { - if (!supportRayTracing()) + if (!supportRayTracing() || data.empty()) return; Gfx::PShaderBuffer verticesBuffer = StaticMeshVertexData::getInstance()->getPositionBuffer(); Gfx::PIndexBuffer indexBuffer = StaticMeshVertexData::getInstance()->getIndexBuffer();