Skip to content

Commit 70fbf31

Browse files
committed
-Dev: Added blur pass for SSAO & Reformat in framebuffer treatmen
1 parent 6010444 commit 70fbf31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+549
-656
lines changed

examples/raytracing/application.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void Application::init(Systems::RendererSettings settings) {
2727
void Application::run(int argc, char* argv[]) {
2828

2929
Systems::RendererSettings settings{};
30+
settings.bufferingType = BufferingType::DOUBLE;
3031
settings.samplesMSAA = MSAASamples::x1;
3132
settings.clearColor = Vec4(0.02, 0.02, 0.02, 1.0);
3233
settings.enableUI = true;
@@ -191,7 +192,7 @@ void Application::setup() {
191192
stormtrooper->set_scale(.7f);
192193
Mesh* stormtrooperHead = new Mesh();
193194
Tools::Loaders::load_3D_file(stormtrooperHead, MESH_PATH + "stormtrooper_helm.obj", false);
194-
auto stormtrooperMat1 = new PhysicallyBasedMaterial();
195+
auto stormtrooperMat1 = new PhysicallyBasedMaterial();
195196
Texture* stormtrooperText11 = new Texture();
196197
Tools::Loaders::load_texture(stormtrooperText11, TEXTURE_PATH + "stormtrooper_head_color.png");
197198
stormtrooperMat1->set_albedo_texture(stormtrooperText11);
@@ -200,13 +201,13 @@ void Application::setup() {
200201
stormtrooperText12, TEXTURE_PATH + "stormtrooper_head_normal.png", TEXTURE_FORMAT_TYPE_NORMAL);
201202
stormtrooperMat1->set_normal_texture(stormtrooperText12);
202203
Texture* stormtrooperText13 = new Texture();
203-
Tools::Loaders::load_texture(stormtrooperText13, TEXTURE_PATH + "stormtrooper_head_mask.png", TEXTURE_FORMAT_TYPE_NORMAL);
204+
Tools::Loaders::load_texture(
205+
stormtrooperText13, TEXTURE_PATH + "stormtrooper_head_mask.png", TEXTURE_FORMAT_TYPE_NORMAL);
204206
stormtrooperMat1->set_mask_texture(stormtrooperText13, MaskType::UNREAL_ENGINE);
205207
stormtrooperHead->push_material(stormtrooperMat1);
206208
stormtrooperHead->set_name("Head");
207209
stormtrooper->add_child(stormtrooperHead);
208210
m_scene->add(stormtrooper);
209-
210211

211212
m_scene->add(plane);
212213

include/engine/common.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ VULKAN_ENGINE_NAMESPACE_BEGIN
116116

117117
// Mathematics library glm
118118
namespace math = glm;
119-
typedef math::vec4 Vec4;
120-
typedef math::vec3 Vec3;
121-
typedef math::vec2 Vec2;
122-
typedef math::mat4 Mat4;
123-
typedef math::mat3 Mat3;
119+
typedef math::vec4 Vec4;
120+
typedef math::vec3 Vec3;
121+
typedef math::ivec3 iVec3;
122+
typedef math::vec2 Vec2;
123+
typedef math::ivec2 iVec2;
124+
typedef math::mat4 Mat4;
125+
typedef math::mat3 Mat3;
124126

125127
typedef VkExtent3D Extent3D;
126128
typedef VkExtent2D Extent2D;

include/engine/core/passes/bloom_pass.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class BloomPass : public BasePass
5050
std::vector<Graphics::Framebuffer> m_bloomFramebuffers;
5151

5252
public:
53-
BloomPass(Graphics::Device* ctx, Extent2D extent, uint32_t framebufferCount, Mesh* vignette, bool isDefault = false)
54-
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "BLOOM")
53+
BloomPass(Graphics::Device* ctx, Extent2D extent, Mesh* vignette, bool isDefault = false)
54+
: BasePass(ctx, extent, 1, 1, isDefault, "BLOOM")
5555
, m_vignette(vignette) {
5656
}
5757

@@ -62,7 +62,7 @@ class BloomPass : public BasePass
6262
m_bloomStrength = st;
6363
}
6464

65-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
65+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
6666
std::vector<Graphics::SubPassDependency>& dependencies);
6767

6868
void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -71,7 +71,7 @@ class BloomPass : public BasePass
7171

7272
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
7373

74-
void connect_to_previous_images(std::vector<Graphics::Image> images);
74+
void link_previous_images(std::vector<Graphics::Image> images);
7575

7676
void update();
7777

include/engine/core/passes/composition_pass.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ class CompositionPass : public GraphicPass
6363
public:
6464
CompositionPass(Graphics::Device* ctx,
6565
VkExtent2D extent,
66-
uint32_t framebufferCount,
6766
ColorFormatType colorFormat,
6867
Mesh* vignette,
6968
bool isDefault = true)
70-
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "COMPOSITION")
69+
: BasePass(ctx, extent, 1, 1, isDefault, "COMPOSITION")
7170
, m_colorFormat(colorFormat)
7271
, m_vignette(vignette) {
7372
}
@@ -91,7 +90,7 @@ class CompositionPass : public GraphicPass
9190
m_settings.enableAO = op;
9291
}
9392

94-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
93+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
9594
std::vector<Graphics::SubPassDependency>& dependencies);
9695

9796
void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -100,7 +99,7 @@ class CompositionPass : public GraphicPass
10099

101100
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
102101

103-
void connect_to_previous_images(std::vector<Graphics::Image> images);
102+
void link_previous_images(std::vector<Graphics::Image> images);
104103

105104
void update_uniforms(uint32_t frameIndex, Scene* const scene);
106105

include/engine/core/passes/forward_pass.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#ifndef FORWARD_PASS_H
1010
#define FORWARD_PASS_H
1111
#include <engine/core/passes/pass.h>
12+
#include <engine/core/resource_manager.h>
1213
#include <engine/core/textures/texture.h>
1314
#include <engine/core/textures/textureLDR.h>
14-
#include <engine/core/resource_manager.h>
1515

1616
VULKAN_ENGINE_NAMESPACE_BEGIN
1717

@@ -39,18 +39,17 @@ class ForwardPass : public GraphicPass
3939
public:
4040
ForwardPass(Graphics::Device* ctx,
4141
Extent2D extent,
42-
uint32_t framebufferCount,
4342
ColorFormatType colorFormat,
4443
ColorFormatType depthFormat,
4544
MSAASamples samples,
4645
bool isDefault = true)
47-
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "FORWARD")
46+
: BasePass(ctx, extent, 1, isDefault, "FORWARD")
4847
, m_colorFormat(colorFormat)
4948
, m_depthFormat(depthFormat)
5049
, m_aa(samples) {
5150
}
5251

53-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
52+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
5453
std::vector<Graphics::SubPassDependency>& dependencies);
5554

5655
void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -61,7 +60,7 @@ class ForwardPass : public GraphicPass
6160

6261
void update_uniforms(uint32_t frameIndex, Scene* const scene);
6362

64-
void connect_to_previous_images(std::vector<Graphics::Image> images);
63+
void link_previous_images(std::vector<Graphics::Image> images);
6564

6665
void set_envmap_descriptor(Graphics::Image env, Graphics::Image irr);
6766
};

include/engine/core/passes/geometry_pass.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ class GeometryPass : public GraphicPass
3636
public:
3737
GeometryPass(Graphics::Device* ctx,
3838
Extent2D extent,
39-
uint32_t framebufferCount,
4039
ColorFormatType colorFormat,
4140
ColorFormatType depthFormat,
4241
bool isDefault = false)
43-
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "GEOMETRY")
42+
: BasePass(ctx, extent, 1, 1, isDefault, "GEOMETRY")
4443
, m_colorFormat(colorFormat)
4544
, m_depthFormat(depthFormat) {
4645
}
4746

48-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
47+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
4948
std::vector<Graphics::SubPassDependency>& dependencies);
5049

5150
void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -57,7 +56,6 @@ class GeometryPass : public GraphicPass
5756
void update_uniforms(uint32_t frameIndex, Scene* const scene);
5857

5958
void set_envmap_descriptor(Graphics::Image env, Graphics::Image irr);
60-
6159
};
6260
} // namespace Core
6361
VULKAN_ENGINE_NAMESPACE_END

include/engine/core/passes/irradiance_compute_pass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IrrandianceComputePass : public GraphicPass
2626
, m_format(format) {
2727
}
2828

29-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
29+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
3030
std::vector<Graphics::SubPassDependency>& dependencies);
3131

3232
void setup_uniforms(std::vector<Graphics::Frame>& frames);

include/engine/core/passes/panorama_conversion_pass.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PanoramaConverterPass : public GraphicPass
2828
, m_format(format) {
2929
}
3030

31-
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
31+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
3232
std::vector<Graphics::SubPassDependency>& dependencies);
3333

3434
void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -39,7 +39,6 @@ class PanoramaConverterPass : public GraphicPass
3939

4040
void update_uniforms(uint32_t frameIndex, Scene* const scene);
4141

42-
void connect_to_previous_images(std::vector<Graphics::Image> images);
4342
};
4443

4544
} // namespace Core

include/engine/core/passes/pass.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ class BasePass
4848
std::vector<Graphics::Framebuffer> m_framebuffers;
4949
uint32_t m_framebufferImageDepth; // In case if multilayered rendering.
5050

51+
Extent2D m_imageExtent;
5152
std::string m_name;
5253

53-
// Key: Renderpass ID
54-
// Value: Framebuffer's image ID inside renderpass
55-
std::unordered_map<uint32_t, std::vector<uint32_t>> m_imageDepedanceTable;
54+
// Key: Vec2 (Renderpass ID, Framebuffer ID)
55+
// Value: Framebuffer's image attachment IDs
56+
std::unordered_map<iVec2, std::vector<uint32_t>> m_imageDepedanceTable;
5657

5758
// Query
5859
bool m_initiatized = false;
@@ -62,7 +63,7 @@ class BasePass
6263
bool m_isGraphical = true;
6364

6465
virtual void
65-
setup_attachments(std::vector<Graphics::Attachment>& attachments,
66+
setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
6667
std::vector<Graphics::SubPassDependency>& dependencies) = 0; // Only for graphical renderpasses
6768
virtual void setup_uniforms(std::vector<Graphics::Frame>& frames) = 0;
6869
virtual void setup_shader_passes() = 0;
@@ -73,13 +74,14 @@ class BasePass
7374
uint32_t framebufferCount = 1,
7475
uint32_t framebufferDepth = 1,
7576
bool isDefault = false,
76-
std::string name = "Graphic Pass")
77+
std::string name = "UNNAMED PASS")
7778
: m_device(ctx)
7879
, m_framebufferImageDepth(framebufferDepth)
7980
, m_isDefault(isDefault)
8081
, m_name(name) {
81-
m_framebuffers.resize(framebufferCount);
82-
m_renderpass.extent = extent;
82+
!isDefault ? m_framebuffers.resize(framebufferCount)
83+
: m_framebuffers.resize(m_device->get_swapchain().get_present_images().size());
84+
m_imageExtent = extent;
8385
}
8486

8587
#pragma region Getters & Setters
@@ -92,24 +94,20 @@ class BasePass
9294
}
9395

9496
inline Extent2D get_extent() const {
95-
return m_renderpass.extent;
97+
return m_imageExtent;
9698
}
9799
inline void set_extent(Extent2D extent) {
98-
m_renderpass.extent = extent;
100+
m_imageExtent = extent;
99101
}
100102

101-
inline Graphics::RenderPass get_handle() const {
103+
inline Graphics::RenderPass get_renderpass() const {
102104
return m_renderpass;
103105
}
104106
inline std::vector<Graphics::Framebuffer> const get_framebuffers() const {
105107
return m_framebuffers;
106108
}
107-
108-
inline std::vector<Graphics::Attachment> get_attachments() {
109-
return m_renderpass.attachments;
110-
}
111109
inline void set_attachment_clear_value(VkClearValue value, size_t attachmentLayout = 0) {
112-
m_renderpass.attachments[attachmentLayout].clearValue = value;
110+
m_renderpass.attachmentsInfo[attachmentLayout].clearValue = value;
113111
}
114112

115113
inline bool resizeable() const {
@@ -137,13 +135,14 @@ class BasePass
137135
}
138136

139137
/*
140-
Sets a table of connection with different passes. Key is the pass ID and value
141-
is the atachment number
138+
Sets a table of depedencies with different passes.
139+
- Key: Vec2 (Renderpass ID, Framebuffer ID)
140+
- Value: array of framebuffer's image attachment IDs
142141
*/
143-
inline void set_image_dependace_table(std::unordered_map<uint32_t, std::vector<uint32_t>> table) {
142+
inline void set_image_dependace_table(std::unordered_map<iVec2, std::vector<uint32_t>> table) {
144143
m_imageDepedanceTable = table;
145144
}
146-
inline std::unordered_map<uint32_t, std::vector<uint32_t>> get_image_dependace_table() const {
145+
inline std::unordered_map<iVec2, std::vector<uint32_t>> get_image_dependace_table() const {
147146
return m_imageDepedanceTable;
148147
}
149148

@@ -158,7 +157,7 @@ class BasePass
158157

159158
virtual void update_uniforms(uint32_t frameIndex, Scene* const scene) {
160159
}
161-
virtual void connect_to_previous_images(std::vector<Graphics::Image> images) {
160+
virtual void link_previous_images(std::vector<Graphics::Image> images) {
162161
}
163162
/**
164163
* Create framebuffers and images attached to them necessary for the

include/engine/core/passes/postprocess_pass.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ class PostProcessPass : public GraphicPass
2828
public:
2929
PostProcessPass(Graphics::Device* ctx,
3030
Extent2D extent,
31-
uint32_t framebufferCount,
3231
ColorFormatType colorFormat,
3332
Mesh* vignette,
3433
std::string shaderPath,
3534
std::string name = "POST-PROCESS",
3635
bool isDefault = true)
37-
: BasePass(ctx, extent, framebufferCount, 1, isDefault, name)
36+
: BasePass(ctx, extent, 1, 1, isDefault, name)
3837
, m_colorFormat(colorFormat)
3938
, m_vignette(vignette)
4039
, m_shaderPath(shaderPath) {
4140
}
4241

43-
virtual void setup_attachments(std::vector<Graphics::Attachment>& attachments,
42+
virtual void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
4443
std::vector<Graphics::SubPassDependency>& dependencies);
4544

4645
virtual void setup_uniforms(std::vector<Graphics::Frame>& frames);
@@ -49,7 +48,11 @@ class PostProcessPass : public GraphicPass
4948

5049
virtual void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
5150

52-
virtual void connect_to_previous_images(std::vector<Graphics::Image> images);
51+
virtual void link_previous_images(std::vector<Graphics::Image> images);
52+
53+
void clean_framebuffer() {
54+
GraphicPass::clean_framebuffer();
55+
}
5356
};
5457

5558
} // namespace Core

0 commit comments

Comments
 (0)