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

[gltf] Add glTF2 loader and pbr renderer #270

Draft
wants to merge 127 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
4d6bed9
[conan] Update tinygltf to version 2.5.0
IAmNotHanni May 10, 2021
e4862b0
[gltf-file] Added small wrapper class for tinygltf library
IAmNotHanni May 10, 2021
e155e97
[gltf2-file] Fix clang-tidy warnings (squash me)
IAmNotHanni May 10, 2021
b49661f
[gltf2-file] Fix clang-tidy warnings (squash me)
IAmNotHanni May 10, 2021
fe404c8
[gltf-model|gltf-file] Add basic glTF2 model file loader
IAmNotHanni May 10, 2021
91da276
[gltf-model] Fix clang build
IAmNotHanni May 10, 2021
549d8b8
[gltf-model|gltf-file] Fix clang-tidy
IAmNotHanni May 10, 2021
61cb447
[*] Small fixes
IAmNotHanni May 10, 2021
64448e0
[*] Small fixes
IAmNotHanni May 10, 2021
4a00a08
[gltf-model] Improve conversion of rgb data to rgba (thanks to user a…
IAmNotHanni May 11, 2021
6b7b644
[gltf-model] Add default destructor
IAmNotHanni May 11, 2021
6299883
[gltf] Add nolints for pointer arithmetics
IAmNotHanni May 23, 2021
d5c2945
[gltf] Refactoring
IAmNotHanni Jul 24, 2021
b52ff56
[gltf-model] Fix scene loop, add get methods, and prefer emplace_back…
IAmNotHanni Jul 24, 2021
a61651e
[gltf] Set up loading of gltf sample file
IAmNotHanni Jul 25, 2021
224e574
[gltf] Fix model loading
IAmNotHanni Jul 25, 2021
65cc6c2
[gltf] Small improvements
IAmNotHanni Jul 26, 2021
9883100
[gltf-model] Change spdlog messages from debug to trace
IAmNotHanni Jul 26, 2021
4ae6fb1
[gltf] Rework
IAmNotHanni Jul 28, 2021
5ebe47b
[gltf] Trying to get glTF rendering working
IAmNotHanni Jul 28, 2021
806c929
[gltf|render-graph] Fix gltf rendering setup in rendergraph
yeetari Jul 29, 2021
5a76282
[gltf] Fix clang-tidy warnings about namespaces
IAmNotHanni Jul 30, 2021
d442719
[gltf] Fix clang-tidy
IAmNotHanni Jul 30, 2021
5bba8c7
[gltf] WIP
IAmNotHanni Jul 30, 2021
96300e9
[shaders] Backup
IAmNotHanni Jul 31, 2021
4b8ae3f
[gltf] WIP
IAmNotHanni Jul 31, 2021
fb2aa66
[gltf] WIP
IAmNotHanni Jul 31, 2021
f32409b
[gltf] WIP
IAmNotHanni Jul 31, 2021
e2b5f21
[gltf] WIP
IAmNotHanni Jul 31, 2021
94f81f3
[gltf] Fix build
IAmNotHanni Jul 31, 2021
7287190
[gltf] WIP
IAmNotHanni Aug 1, 2021
9a52f36
[gltf] WIP
IAmNotHanni Aug 4, 2021
4b77d2d
[gltf] WIP broken
IAmNotHanni Aug 4, 2021
f8964cf
[gltf] WIP
IAmNotHanni Aug 6, 2021
601693c
[gltf] WIP
IAmNotHanni Aug 6, 2021
e865f7d
[gltf] WIP
IAmNotHanni Aug 6, 2021
3180590
[gltf] WIP
IAmNotHanni Aug 6, 2021
44ab701
[gltf] WIP broken
IAmNotHanni Aug 7, 2021
4fac42d
[gltf] WIP
IAmNotHanni Aug 7, 2021
9a6af5b
[gltf] Fix build
IAmNotHanni Aug 7, 2021
ab0950a
[gltf] WIP
IAmNotHanni Aug 8, 2021
457dbe0
[gltf] Fix build
IAmNotHanni Aug 8, 2021
81bd6b4
[gltf] WIP
IAmNotHanni Aug 8, 2021
eebe8ff
[gltf] Fix some clang-tidy warnings
IAmNotHanni Aug 8, 2021
1eb4652
[gltf] Refactor material loading
IAmNotHanni Aug 8, 2021
8f34a45
[gltf] Print list of unsupported glTF material features
IAmNotHanni Aug 8, 2021
69e04e9
[gltf] Use one vertex and index buffer per model, not per scene
IAmNotHanni Aug 8, 2021
ba5f9ce
[gltf] Fix some clang-tidy warnings
IAmNotHanni Aug 8, 2021
2c0648f
[gltf] Load model skins
IAmNotHanni Aug 8, 2021
d8e7d63
[*] Do not worry I will split that up into atomic commits
IAmNotHanni Aug 9, 2021
769221d
[gltf] WIP
IAmNotHanni Aug 10, 2021
ef26e6d
[gltf] Fix build
IAmNotHanni Aug 10, 2021
e1047da
[*] Ah shit, here we go again
IAmNotHanni Sep 24, 2021
f04fa1e
[uniform-buffer] Fix Linux build
IAmNotHanni Sep 26, 2021
3c6405a
[assets] Remove big glTF file
IAmNotHanni Sep 26, 2021
76812fd
[*] backup of WIP
IAmNotHanni Sep 28, 2021
7108e4b
[*] Backup of progress
IAmNotHanni Oct 1, 2021
2d2239b
[*] Fix Linux build
IAmNotHanni Oct 1, 2021
2aba578
[cubemap] Attempt to fix build in Windows
IAmNotHanni Oct 1, 2021
0676881
[*] Backup of image wrapper refactoring
IAmNotHanni Oct 2, 2021
851ad37
[*] Backup of cubemap WIP
IAmNotHanni Oct 3, 2021
d0b610c
[*] Backup of work
IAmNotHanni Oct 11, 2021
33a7f97
[*] Backup of work despite validation layer errors
IAmNotHanni Oct 30, 2021
738223f
[*] Fix validation layer errors
IAmNotHanni Oct 31, 2021
e2008cb
[*] Backup and trying to fix build
IAmNotHanni Nov 1, 2021
2fc9020
[*] Fix build
IAmNotHanni Nov 1, 2021
5adad75
[*] Backup of work
IAmNotHanni Nov 3, 2021
7c81db2
[*] Backup of work. Refactoring shader loading
IAmNotHanni Nov 4, 2021
450829c
[*] Further reduce console log messages to reduce spam
IAmNotHanni Nov 4, 2021
c63a6b1
[*] Fix octree and ImGui rendering and disable glTF rendering
IAmNotHanni Nov 4, 2021
ee28232
[conan] Add ktx dependency
IAmNotHanni Nov 4, 2021
f7cb070
[assets] Add new assets
IAmNotHanni Nov 7, 2021
2bacd20
[*] Backup of work (broken)
IAmNotHanni Nov 7, 2021
bfd7aa7
[ci] Update Vulkan SDK version
IAmNotHanni Nov 6, 2021
2fe2fc7
[byte-stream|cube] Fix clang-tidy warnings
IAmNotHanni Nov 6, 2021
32afeec
[clang-tidy] Ignore portability-simd-intrinsics
IAmNotHanni Nov 6, 2021
394e901
[*] Backup of work
IAmNotHanni Nov 7, 2021
a24b4c1
[*] Backup of work
IAmNotHanni Nov 8, 2021
0a61cbb
[*] Fix cubemap code
IAmNotHanni Nov 8, 2021
8fc49d1
[*] Backup of work
IAmNotHanni Nov 9, 2021
ed8c85b
[*] Fix some clang warnings
IAmNotHanni Nov 9, 2021
30f4996
[*] Backup of work
IAmNotHanni Nov 9, 2021
c1bbfed
[*] Make UniformBuffer a full template class
IAmNotHanni Nov 9, 2021
d57c295
[*] Backup of work
IAmNotHanni Nov 10, 2021
841451f
[*] Backup of work
IAmNotHanni Nov 11, 2021
d8596d1
[*] Backup of work
IAmNotHanni Nov 11, 2021
303548d
[application] Fix octree regeneration code
IAmNotHanni Nov 11, 2021
8468349
[*] Backup of work
IAmNotHanni Nov 12, 2021
8324f10
[*] Backup of work
IAmNotHanni Nov 13, 2021
35c753f
[*] Backup of work
IAmNotHanni Nov 14, 2021
a0e5b94
[*] Backup of work
IAmNotHanni Jan 1, 2022
2632b22
[*] Backup of work
IAmNotHanni Jan 3, 2022
b05bd62
[*] Backup of work
IAmNotHanni Jan 5, 2022
39c3169
[*] Backup of work
IAmNotHanni Jan 8, 2022
b6aa5ed
[*] Backup of work
IAmNotHanni Jan 9, 2022
c676d4c
[*] Backup of work
IAmNotHanni Jan 9, 2022
3280f45
[*] Backup of work
IAmNotHanni Jan 9, 2022
4ba175d
[*] Backup of work
IAmNotHanni Jan 10, 2022
6ccf738
[*] Backup of work
IAmNotHanni Jan 10, 2022
f70dc48
[*] Backup of work
IAmNotHanni Jan 10, 2022
1ca05ee
[*] Backup of work, skybox renderer working
IAmNotHanni Jan 25, 2022
2935ee2
[*] Backup of work, skybox is rendering
IAmNotHanni Jan 28, 2022
42ae246
[*] Backup of work
IAmNotHanni Jan 29, 2022
9087acd
[*] Backup of work
IAmNotHanni Jan 30, 2022
6b97f17
[*] Backup of work
IAmNotHanni Jan 30, 2022
77328af
[*] Backup of work
IAmNotHanni Jan 30, 2022
e6af513
[*] Backup of work
IAmNotHanni Jan 30, 2022
31e503b
[*] Backup of work, model vertices are being loaded and rendered
IAmNotHanni Mar 12, 2022
0b86863
[*] Backup of work
IAmNotHanni Mar 12, 2022
19cd038
[gltf-gpu-data-base] Minor fixes
IAmNotHanni Mar 14, 2022
d897109
[*] Backup of work
IAmNotHanni Mar 18, 2022
64cb3fc
[*] Add RAII wrapper for pipeline layouts
IAmNotHanni Mar 19, 2022
52f92a1
[*] Backup of work
IAmNotHanni Mar 19, 2022
8ceab57
[*] Backup of work (broken)
IAmNotHanni Mar 20, 2022
67994c6
[*] Backup of work
IAmNotHanni Mar 23, 2022
75fc79b
[*] Backup of work
IAmNotHanni Mar 24, 2022
67d1302
[*] Update of work
IAmNotHanni Mar 29, 2022
0d46616
[*] Backup of work
IAmNotHanni Apr 2, 2022
67e61eb
[*] Fix build
IAmNotHanni Apr 2, 2022
958be42
[*] Backup of work
IAmNotHanni Apr 3, 2022
3672d9a
[*] Backup of work
IAmNotHanni Apr 3, 2022
1b8cd84
[*] Backup of work
IAmNotHanni Apr 9, 2022
bbf9fcf
[*] Backup of work
IAmNotHanni Apr 10, 2022
72a2237
[*] Backup of work
IAmNotHanni Apr 11, 2022
f00740e
[*] Backup of work
IAmNotHanni Apr 18, 2022
ec6cff7
[*] Backup of work
IAmNotHanni Apr 18, 2022
bf7ca5e
[*] Backup of work
IAmNotHanni Apr 24, 2022
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
Prev Previous commit
Next Next commit
[*] Backup of progress
  • Loading branch information
IAmNotHanni committed Oct 1, 2021
commit 7108e4b85ebd9070634f619fd1e6c6ec108858c1
20 changes: 19 additions & 1 deletion include/inexor/vulkan-renderer/cubemap/cubemap.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#pragma once

#include "inexor/vulkan-renderer/wrapper/device.hpp"
#include "inexor/vulkan-renderer/wrapper/image.hpp"
#include "inexor/vulkan-renderer/wrapper/offscreen_framebuffer.hpp"

#include <memory>

namespace inexor::vulkan_renderer::cubemap {

class Cubemap {};
/// @brief A wrapper class for cubemaps
class Cubemap {

private:
std::unique_ptr<wrapper::Image> m_cubemap_image;
std::unique_ptr<wrapper::OffscreenFramebuffer> m_offscreen_framebuffer;
VkSampler m_sampler{VK_NULL_HANDLE};

public:
///
///
Cubemap(const wrapper::Device &device);
};

} // namespace inexor::vulkan_renderer::cubemap
2 changes: 1 addition & 1 deletion include/inexor/vulkan-renderer/wrapper/gpu_texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class GpuTexture {
}

[[nodiscard]] VkImage image() const {
return m_texture_image->get();
return m_texture_image->image();
}

[[nodiscard]] VkImageView image_view() const {
Expand Down
103 changes: 91 additions & 12 deletions include/inexor/vulkan-renderer/wrapper/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,104 @@ class Device;

/// @brief RAII wrapper class for VkImage.
class Image {
const wrapper::Device &m_device;
const Device &m_device;
VmaAllocation m_allocation{VK_NULL_HANDLE};
VmaAllocationInfo m_allocation_info{};
VkImage m_image{VK_NULL_HANDLE};
VkFormat m_format{VK_FORMAT_UNDEFINED};
VkImageView m_image_view{VK_NULL_HANDLE};
std::string m_name;

/// @brief Call vmaCreateImage and assign an internal debug marker name.
/// @param image_ci The image create info
void create_image(VkImageCreateInfo image_ci);

/// @brief Call vkCreateImageView and assign an internal debug marker name.
/// @param image_view_ci The image view create info
void create_image_view(VkImageViewCreateInfo image_view_ci);

public:
/// @brief Default constructor.
/// @param device The const reference to a device RAII wrapper instance.
/// @param format The color format.
/// @param image_usage The image usage flags.
/// @param aspect_flags The aspect flags.
/// @param sample_count The sample count.
/// @param name The internal debug marker name of the VkImage.
/// @param image_extent The width and height of the image.
Image(const Device &device, VkFormat format, VkImageUsageFlags image_usage, VkImageAspectFlags aspect_flags,
VkSampleCountFlagBits sample_count, const std::string &name, VkExtent2D image_extent);
/// @brief This is the most verbose constructor. It offers all create structures as parameters.
/// @note More constructors with increasing amount of abstraction can be found below. Not that this constructor is
/// the most explicit because you have to fill out ``VkImageCreateInfo`` and ``VkImageViewCreateInfo`` manually.
/// @param device The device wrapper
/// @param image_ci The image create info
/// @param image_view_ci The image view create info
/// @param name The internal debug marker name of the image
/// @note std::move(name) is used since we must take ownership of the memory for assigning a Vulkan debug marker
Image(const Device &device, VkImageCreateInfo image_ci, VkImageViewCreateInfo image_view_ci, std::string name);

/// @brief Call the constructor above, but expose most parameters to the programmer.
/// @param device The device wrapper
/// @param flags The image creation flags
/// @param image_type The type of the image
/// @param format The image format
/// @param width The width of the image in pixels
/// @param height The height of the image in pixels
/// @param miplevel_count The number of mip levels
/// @param layer_count The number of layers in the image
/// @param sample_count The number of samples per pixel
/// @param usage_flags The image usage flags
/// @param view_type The view type of the image view
/// @param view_components The component bits of the image view
/// @param aspect_mask The aspect mask of the image view
/// @param name The internal debug marker name of the image
/// @note std::move(name) is used since we must take ownership of the memory for assigning a Vulkan debug marker
Image(const Device &device, VkImageCreateFlags flags, VkImageType image_type, VkFormat format, std::uint32_t width,
std::uint32_t height, std::uint32_t miplevel_count, std::uint32_t layer_count,
VkSampleCountFlagBits sample_count, VkImageUsageFlags usage_flags, VkImageViewType view_type,
VkComponentMapping view_components, VkImageAspectFlags aspect_mask, std::string name);

/// @brief Call constructor #2, but don't expose ``view_components``.
/// @param device The device wrapper
/// @param flags The image creation flags
/// @param image_type The type of the image
/// @param format The image format
/// @param width The width of the image in pixels
/// @param height The height of the image in pixels
/// @param miplevel_count The number of mip levels
/// @param layer_count The number of layers in the image
/// @param sample_count The number of samples per pixel
/// @param usage_flags The image usage flags
/// @param view_type The view type of the image view
/// @param aspect_mask The aspect mask of the image view
/// @param name The internal debug marker name of the image
/// @note std::move(name) is used since we must take ownership of the memory for assigning a Vulkan debug marker
Image(const Device &device, VkImageCreateFlags flags, VkImageType image_type, VkFormat format, std::uint32_t width,
std::uint32_t height, std::uint32_t miplevel_count, std::uint32_t layer_count,
VkSampleCountFlagBits sample_count, VkImageUsageFlags usage_flags, VkImageViewType view_type,
VkImageAspectFlags aspect_mask, std::string name);

/// @brief Call constructor #2, but don't expose ``flags``.
/// @param device The device wrapper
/// @param image_type The type of the image
/// @param format The image format
/// @param width The width of the image in pixels
/// @param height The height of the image in pixels
/// @param miplevel_count The number of mip levels
/// @param layer_count The number of layers in the image
/// @param sample_count The number of samples per pixel
/// @param usage_flags The image usage flags
/// @param view_type The view type of the image view
/// @param aspect_mask The aspect mask of the image view
/// @param name The internal debug marker name of the image
/// @note std::move(name) is used since we must take ownership of the memory for assigning a Vulkan debug marker
Image(const Device &device, VkImageType image_type, VkFormat format, std::uint32_t width, std::uint32_t height,
std::uint32_t miplevel_count, std::uint32_t layer_count, VkSampleCountFlagBits sample_count,
VkImageUsageFlags usage_flags, VkImageViewType view_type, VkImageAspectFlags aspect_mask, std::string name);

/// @brief Call constructor #2, but don't expose ``image_type``, ``miplevel_count``, ``layer_count``,
/// ``sample_count``, and ``view_type``.
/// @param device The device wrapper
/// @param format The image format
/// @param width The width of the image in pixels
/// @param height The height of the image in pixels
/// @param usage_flags The image usage flags
/// @param aspect_mask The aspect mask of the image view
/// @param name The internal debug marker name of the image
/// @note std::move(name) is used since we must take ownership of the memory for assigning a Vulkan debug marker
Image::Image(const Device &device, VkFormat format, std::uint32_t width, std::uint32_t height,
VkImageUsageFlags usage_flags, VkImageAspectFlags aspect_mask, std::string name);

Image(const Image &) = delete;
Image(Image &&) noexcept;
Expand All @@ -47,7 +126,7 @@ class Image {
return m_image_view;
}

[[nodiscard]] VkImage get() const {
[[nodiscard]] VkImage image() const {
return m_image;
}
};
Expand Down
26 changes: 26 additions & 0 deletions include/inexor/vulkan-renderer/wrapper/offscreen_framebuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "inexor/vulkan-renderer/wrapper/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/framebuffer.hpp"
#include "inexor/vulkan-renderer/wrapper/image.hpp"

#include <memory>

namespace inexor::vulkan_renderer::wrapper {

class OffscreenFramebuffer : public Framebuffer, public Image {

public:
/// @brief Create the framebuffer and its image.
/// @param device The device wrapper
/// @param format The image format
/// @param width The width of the offscreen framebuffer
/// @param height The height of the offscreen framebuffer
/// @param renderpass The VkRenderpass
/// @param attachments The image views
/// @param name The name of the offscreen framebuffer
OffscreenFramebuffer(const wrapper::Device &device, VkFormat format, std::uint32_t width, std::uint32_t height,
VkRenderPass renderpass, const std::vector<VkImageView> &attachments, std::string name);
};

} // namespace inexor::vulkan_renderer::wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class OnceCommandBuffer {

/// @brief Create the command buffer.
/// @note We are not merging this into the constructor because we need to be able to call this function separately.
// TODO: Merge create_command_buffer() into start_recording().
void create_command_buffer();

/// @brief Call vkBeginCommandBuffer.
void start_recording();

/// @brief Call vkEndCommandBuffer and vkFreeCommandBuffers.
// TODO: Check if submit was called!
void end_recording_and_submit_command();

[[nodiscard]] VkCommandBuffer command_buffer() const {
Expand Down
6 changes: 3 additions & 3 deletions shaders/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ set(
SHADERS
brdflut/genbrdflut.frag
brdflut/genbrdflut.vert
gltf/filtercube.vert
gltf/irradiancecube.frag
cubemap/filtercube.vert
cubemap/irradiancecube.frag
cubemap/prefilterenvmap.frag
gltf/pbr.vert
gltf/pbr_khr.frag
gltf/prefilterenvmap.frag
imgui/ui.vert
imgui/ui.frag
octree/main.frag
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(INEXOR_SOURCE_FILES
vulkan-renderer/wrapper/image.cpp
vulkan-renderer/wrapper/instance.cpp
vulkan-renderer/wrapper/make_info.cpp
vulkan-renderer/wrapper/offscreen_framebuffer.cpp
vulkan-renderer/wrapper/once_command_buffer.cpp
vulkan-renderer/wrapper/semaphore.cpp
vulkan-renderer/wrapper/shader.cpp
Expand Down
Loading