Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce SDF Global Illumination #25

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ include_directories(Dependencies/src/vulkan/include)
include_directories(Dependencies/src/vma/src)
include_directories(Dependencies/src/glfw/include)
include_directories(Dependencies/src/glm)
include_directories(Dependencies/src/assimp/include)
include_directories(Dependencies/src/tinygltf)
include_directories(Dependencies/src/etc2comp/EtcLib/Etc)
include_directories(Dependencies/src/etc2comp/EtcLib/EtcCodec)
include_directories(Dependencies/src/glslang/glslang/Include)
Expand Down Expand Up @@ -103,16 +103,6 @@ set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
set(GLFW_INSTALL OFF CACHE BOOL "")
add_subdirectory(Dependencies/src/glfw)

set(ASSIMP_NO_EXPORT ON CACHE BOOL "")
set(ASSIMP_BUILD_DRACO OFF CACHE BOOL "")
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "")
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "")
set(ASSIMP_INSTALL_PDB OFF CACHE BOOL "")
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF CACHE BOOL "")
set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_GLTF_IMPORTER ON CACHE BOOL "")
add_subdirectory(Dependencies/src/assimp)

set(MESHOPT_BUILD_DEMO OFF CACHE BOOL "")
set(MESHOPT_BUILD_TOOLS OFF CACHE BOOL "")
set(MESHOPT_BUILD_SHARED_LIBS OFF CACHE BOOL "")
Expand Down Expand Up @@ -153,15 +143,10 @@ add_subdirectory(Dependencies/src/backward-cpp)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET glfw PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET assimp PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET EtcLib PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET EtcTool PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET meshoptimizer PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET volk PROPERTY FOLDER "ThirdPartyLibraries")
if(WIN32)
set_property(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs PROPERTY FOLDER "ThirdPartyLibraries")
endif()
set_property(TARGET uninstall PROPERTY FOLDER "ThirdPartyLibraries")
set_property(TARGET glslang PROPERTY FOLDER "ThirdPartyLibraries/glslang")
set_property(TARGET OGLCompiler PROPERTY FOLDER "ThirdPartyLibraries/glslang")
set_property(TARGET OSDependent PROPERTY FOLDER "ThirdPartyLibraries/glslang")
Expand Down
6 changes: 3 additions & 3 deletions Dependencies/bootstrap.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
}
},
{
"name": "assimp",
"name": "tinygltf",
"source": {
"type": "git",
"url": "https://github.com/assimp/assimp.git",
"revision": "a9f82dbe0b8a658003f93c7b5108ee4521458a18"
"url": "https://github.com/syoyo/tinygltf.git",
"revision": "v2.8.18"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Includes/VoxFlow/Core/Devices/LogicalDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <VoxFlow/Core/Devices/Queue.hpp>
#include <VoxFlow/Core/Utils/NonCopyable.hpp>
#include <VoxFlow/Core/Utils/RendererCommon.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>
#include <functional>
#include <glm/vec2.hpp>
#include <memory>
#include <unordered_map>

Expand Down
2 changes: 1 addition & 1 deletion Includes/VoxFlow/Core/Devices/SwapChain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <volk/volk.h>
#include <VoxFlow/Core/Utils/NonCopyable.hpp>
#include <VoxFlow/Core/Utils/RendererCommon.hpp>
#include <glm/vec2.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>
#include <optional>

struct GLFWwindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <VoxFlow/Core/Utils/BitwiseOperators.hpp>
#include <VoxFlow/Core/Utils/HashUtil.hpp>
#include <VoxFlow/Core/Utils/RendererCommon.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>
#include <array>
#include <glm/vec2.hpp>

namespace VoxFlow
{
Expand Down
14 changes: 14 additions & 0 deletions Includes/VoxFlow/Core/Scene/Material.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Author : snowapril

#ifndef VOX_FLOW_MATERIAL_HPP
#define VOX_FLOW_MATERIAL_HPP

namespace VoxFlow
{
class Material
{
public:
};
} // namespace VoxFlow

#endif // VOX_FLOW_MATERIAL_HPP
14 changes: 14 additions & 0 deletions Includes/VoxFlow/Core/Scene/PrimitiveBufferPool.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Author : snowapril

#ifndef VOX_FLOW_PRIMITIVE_BUFFER_POOL_HPP
#define VOX_FLOW_PRIMITIVE_BUFFER_POOL_HPP

namespace VoxFlow
{
class PrimitiveBufferPool
{
public:
};
} // namespace VoxFlow

#endif // VOX_FLOW_PRIMITIVE_BUFFER_POOL_HPP
14 changes: 14 additions & 0 deletions Includes/VoxFlow/Core/Scene/SceneObject.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Author : snowapril

#ifndef VOX_FLOW_SCENE_OBJECT_HPP
#define VOX_FLOW_SCENE_OBJECT_HPP

namespace VoxFlow
{
class SceneObject
{
public:
};
} // namespace VoxFlow

#endif // VOX_FLOW_SCENE_OBJECT_HPP
26 changes: 26 additions & 0 deletions Includes/VoxFlow/Core/Scene/SceneObjectLoader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Author : snowapril

#ifndef VOX_FLOW_SCENE_OBJECT_LOADER_HPP
#define VOX_FLOW_SCENE_OBJECT_LOADER_HPP

#include <volk/volk.h>
#include <memory>
#include <string>

namespace VoxFlow
{
class SceneObject;
class ResourceUploadContext;

class SceneObjectLoader
{
public:
SceneObjectLoader();
~SceneObjectLoader();

public:
std::shared_ptr<SceneObject> loadSceneObjectGltf(const std::string& objPath, ResourceUploadContext* uploadContext);
};
} // namespace VoxFlow

#endif // VOX_FLOW_SCENE_OBJECT_LOADER_HPP
54 changes: 41 additions & 13 deletions Includes/VoxFlow/Core/Utils/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,51 @@ namespace VoxFlow
} \
} while (false)

template <typename... Args>
void voxAssertImpl(bool expr, const char* fmt, Args... args)
{
do
{
if (!static_cast<bool>(expr))
{
spdlog::error("{} at {}:{}.", fmt, args..., __FILE__, __LINE__);
DebugUtil::DebugBreak();
}
#define VOX_ASSERT(expr, msg, ...) \
do \
{ \
if (!static_cast<bool>(expr)) \
{ \
spdlog::error("{} at {}:{}.", fmt, args..., __FILE__, __LINE__); \
DebugUtil::DebugBreak(); \
} \
} while (false);
#define VOX_ASSERT_RETURN_VOID(expr, msg, ...) \
do \
{ \
if (!static_cast<bool>(expr)) \
{ \
spdlog::error("{} at {}:{}.", fmt, args..., __FILE__, __LINE__); \
DebugUtil::DebugBreak(); \
return; \
} \
} while (false);
#define VOX_ASSERT_RETURN_BOOL(expr, msg, ...) \
do \
{ \
if (!static_cast<bool>(expr)) \
{ \
spdlog::error("{} at {}:{}.", fmt, args..., __FILE__, __LINE__); \
DebugUtil::DebugBreak(); \
return false; \
} \
} while (false);
#define VOX_ASSERT_RETURN_NULL(expr, msg, ...) \
do \
{ \
if (!static_cast<bool>(expr)) \
{ \
spdlog::error("{} at {}:{}.", fmt, args..., __FILE__, __LINE__); \
DebugUtil::DebugBreak(); \
return nullptr; \
} \
} while (false);
}

#define VOX_ASSERT(expr, msg, ...) voxAssertImpl(expr, msg, ##__VA_ARGS__)
// #else
// #define VK_ASSERT(x)
// #define VOX_ASSERT(x, msg, ...)
// #define VOX_ASSERT_RETURN_VOID(expr, msg, ...)
// #define VOX_ASSERT_RETURN_BOOL(expr, msg, ...)
// #define VOX_ASSERT_RETURN_NULL(expr, msg, ...)
// #endif

} // namespace VoxFlow
Expand Down
19 changes: 19 additions & 0 deletions Includes/VoxFlow/Core/Utils/MathUtils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Author : snowapril

#ifndef VOXEL_FLOW_MATH_UTILS_HPP
#define VOXEL_FLOW_MATH_UTILS_HPP

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

namespace VoxFlow
{

}

#endif // VOXEL_FLOW_MATH_UTILS_HPP
4 changes: 1 addition & 3 deletions Includes/VoxFlow/Core/Utils/RendererCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include <volk/volk.h>
#include <VoxFlow/Core/Utils/BitwiseOperators.hpp>
#include <VoxFlow/Core/Utils/HashUtil.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>
#include <functional>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <memory>
#include <optional>
#include <string>
Expand Down
38 changes: 38 additions & 0 deletions Includes/VoxFlow/Editor/RenderPass/SDFGlobalIlluminationPass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Author : snowapril

#ifndef VOXEL_FLOW_SDF_GLOBAL_ILLUMINATION_PASS_HPP
#define VOXEL_FLOW_SDF_GLOBAL_ILLUMINATION_PASS_HPP

#include <VoxFlow/Core/FrameGraph/Resource.hpp>
#include <VoxFlow/Core/Renderer/SceneRenderPass.hpp>
#include <VoxFlow/Core/Utils/NonCopyable.hpp>
#include <memory>

namespace VoxFlow
{
class RenderDevice;
class Buffer;
class LogicalDevice;

namespace RenderGraph
{
class FrameGraph;
}

class SDFGlobalIlluminationPass : public SceneRenderPass
{
public:
SDFGlobalIlluminationPass(LogicalDevice* logicalDevice);
~SDFGlobalIlluminationPass() override;

public:
bool initialize() override;
void updateRender(ResourceUploadContext* uploadContext) override;
void renderScene(RenderGraph::FrameGraph* frameGraph) override;

protected:
LogicalDevice* _logicalDevice = nullptr;
};
} // namespace VoxFlow

#endif
9 changes: 9 additions & 0 deletions Sources/VoxFlow/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ set(PUBLIC_HDRS
${PUBLIC_HDR_DIR}/VoxFlow/Core/Resources/RenderResourceGarbageCollector.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Resources/RenderResourceMemoryPool.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Resources/StagingBufferContext.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Scene/SceneObject.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Scene/SceneObjectLoader.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Scene/PrimitiveBufferPool.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Scene/Material.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/BitwiseOperators.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/ChromeTracer.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/DebugUtil.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/HashUtil.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/DecisionMaker.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/DeviceInputSubscriber.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/Logger.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/MathUtils.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/Thread.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/MemoryAllocator.hpp
${PUBLIC_HDR_DIR}/VoxFlow/Core/Utils/NonCopyable.hpp
Expand Down Expand Up @@ -139,6 +144,10 @@ set(SRCS
${SRC_DIR}/Core/Resources/RenderResourceMemoryPool.cpp
${SRC_DIR}/Core/Resources/StagingBufferContext.cpp
${SRC_DIR}/Core/Resources/StagingBuffer.cpp
${SRC_DIR}/Core/Scene/SceneObject.cpp
${SRC_DIR}/Core/Scene/SceneObjectLoader.cpp
${SRC_DIR}/Core/Scene/PrimitiveBufferPool.cpp
${SRC_DIR}/Core/Scene/Material.cpp
${SRC_DIR}/Core/Utils/ChromeTracer.cpp
${SRC_DIR}/Core/Utils/DecisionMaker.cpp
${SRC_DIR}/Core/Utils/DeviceInputSubscriber.cpp
Expand Down
2 changes: 1 addition & 1 deletion Sources/VoxFlow/Core/Devices/Queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <VoxFlow/Core/Utils/DebugUtil.hpp>
#include <VoxFlow/Core/Utils/Logger.hpp>
#include <VoxFlow/Core/Utils/RendererCommon.hpp>
#include <glm/common.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>

namespace VoxFlow
{
Expand Down
3 changes: 1 addition & 2 deletions Sources/VoxFlow/Core/Devices/SwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#include <VoxFlow/Core/Resources/Texture.hpp>
#include <VoxFlow/Core/Utils/Logger.hpp>
#include <VoxFlow/Core/Utils/RendererCommon.hpp>

#include <GLFW/glfw3.h>
#include <glm/common.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>

namespace VoxFlow
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/VoxFlow/Core/FrameGraph/FrameGraphPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <VoxFlow/Core/FrameGraph/FrameGraphResources.hpp>
#include <VoxFlow/Core/Graphics/Commands/CommandJobSystem.hpp>
#include <VoxFlow/Core/Resources/Texture.hpp>
#include <glm/common.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>

namespace VoxFlow
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <VoxFlow/Core/Graphics/Descriptors/DescriptorSetConfig.hpp>
#include <VoxFlow/Core/Graphics/Pipelines/ShaderModule.hpp>
#include <VoxFlow/Core/Utils/Logger.hpp>
#include <VoxFlow/Core/Utils/MathUtils.hpp>
#include <algorithm>
#include <glm/common.hpp>

namespace VoxFlow
{
Expand Down
7 changes: 7 additions & 0 deletions Sources/VoxFlow/Core/Scene/Material.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Author : snowapril

#include <VoxFlow/Core/Scene/Material.hpp>

namespace VoxFlow
{
} // namespace VoxFlow
7 changes: 7 additions & 0 deletions Sources/VoxFlow/Core/Scene/PrimitiveBufferPool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Author : snowapril

#include <VoxFlow/Core/Scene/PrimitiveBufferPool.hpp>

namespace VoxFlow
{
} // namespace VoxFlow
7 changes: 7 additions & 0 deletions Sources/VoxFlow/Core/Scene/SceneObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Author : snowapril

#include <VoxFlow/Core/Scene/SceneObject.hpp>

namespace VoxFlow
{
} // namespace VoxFlow
Loading
Loading