| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

GeometrySubpass.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "Subpass.h"
4
5 #include "Lighting/DirectionalLight.hpp"
6 #include "Lighting/PointLight.hpp"
7 #include "Lighting/Lighting.hpp"
8
9 namespace Fling
10 {
11 class CommandBuffer;
12 class LogicalDevice;
13 class FrameBuffer;
14 class MeshRenderer;
15 class Swapchain;
16 class GraphicsPipeline;
17 class Model;
18 class Buffer;
19 class FirstPersonCamera;
20
26 struct DeferredLightSettings
27 {
29 static const UINT32 MaxDirectionalLights = 8;
30
32 static const UINT32 MaxPointLights = 128;
33 };
34
36 struct LightingUbo
37 {
38 alignas(4) UINT32 DirLightCount = 0;
39 alignas(4) UINT32 PointLightCount = 0;
40
41 alignas(16) DirectionalLight DirLightBuffer[DeferredLightSettings::MaxDirectionalLights] = {};
42
43 alignas(16) PointLight PointLightBuffer[DeferredLightSettings::MaxPointLights] = {};
44 };
45
46 struct CameraInfoUbo
47 {
48 glm::mat4 Projection;
49 glm::mat4 ModelView;
50 glm::vec4 CamPos = {};
51 float Gamma = 2.2f;
52 float Exposure = 4.5f;
53 };
54
61 class GeometrySubpass : public Subpass
62 {
63 public:
64 GeometrySubpass(
65 const LogicalDevice* t_Dev,
66 const Swapchain* t_Swap,
67 entt::registry& t_reg,
68 VkRenderPass t_GlobalRenderPass,
69 FirstPersonCamera* t_Cam,
70 FrameBuffer* t_OffscreenDep,
71 std::shared_ptr<Fling::Shader> t_Vert,
72 std::shared_ptr<Fling::Shader> t_Frag
73 );
74
75 virtual ~GeometrySubpass();
76
77 void Draw(CommandBuffer& t_CmdBuf, VkFramebuffer t_PresentFrameBuf, UINT32 t_ActiveFrameInFlight, entt::registry& t_reg, float DeltaTime) override;
78
79 void CreateDescriptorSets(VkDescriptorPool t_Pool, entt::registry& t_reg) override;
80
84 void CreateGraphicsPipeline() override;
85
86 private:
87
88 void OnPointLightAdded(entt::entity t_Ent, entt::registry& t_Reg, PointLight& t_Light);
89
90 void UpdateLightingUBO(entt::registry& t_Reg, UINT32 t_ActiveFrame);
91
92 // Global render pass for frame buffer writes
93 std::shared_ptr<Model> m_QuadModel;
94
95 VkRenderPass m_GlobalRenderPass = VK_NULL_HANDLE;
96
97 const FirstPersonCamera* m_Camera;
98
100 FrameBuffer* m_OffscreenFrameBuf = nullptr;
101
102 // Descriptor sets and Uniform buffers -- one per swap image
103 std::vector<VkDescriptorSet> m_DescriptorSets;
104 std::vector<Buffer*> m_LightingUboBuffers;
105 std::vector<Buffer*> m_CameraUboBuffers;
106
107 std::vector<Buffer*> m_QuadUboBuffer;
108
109 LightingUbo m_LightingUBO = {};
110
111 CameraInfoUbo m_CamInfoUBO = {};
112 };
113 } // namespace Fling
Fling::GeometrySubpass
The geometry subpass is in charge of sending the geometry portion of the Deferred pipeline to the GPU...
Definition: GeometrySubpass.h:61
Fling::CameraInfoUbo::ModelView
glm::mat4 ModelView
Definition: GeometrySubpass.h:49
Fling::Subpass
A subpass represents one part of a RenderPipeline.
Definition: Subpass.h:25
Fling::FirstPersonCamera
A simple first person camera.
Definition: FirstPersonCamera.h:9
Fling::GeometrySubpass::m_QuadModel
std::shared_ptr< Model > m_QuadModel
Definition: GeometrySubpass.h:93
Fling::GeometrySubpass::m_QuadUboBuffer
std::vector< Buffer * > m_QuadUboBuffer
Definition: GeometrySubpass.h:107
Fling::PointLight
Simple representation of a point light in Light Vox.
Definition: PointLight.hpp:12
Fling::LightingUbo
Uniform buffer for passing lights to our final screen pass.
Definition: GeometrySubpass.h:36
Fling::CommandBuffer
Encapsulates functionality of a Vulkan Command buffer.
Definition: CommandBuffer.h:17
Fling::GeometrySubpass::m_CameraUboBuffers
std::vector< Buffer * > m_CameraUboBuffers
Definition: GeometrySubpass.h:105
Fling::LogicalDevice
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
PointLight.hpp
Fling::Swapchain
Represents a swap chain that can be used throughout the program.
Definition: SwapChain.h:21
Fling::DirectionalLight
Simple representation of a directional light for Fling.
Definition: DirectionalLight.hpp:12
Lighting.hpp
Fling::FrameBuffer
Definition: FrameBuffer.h:67
Subpass.h
Fling::CameraInfoUbo::Projection
glm::mat4 Projection
Definition: GeometrySubpass.h:48
Fling::DeferredLightSettings::MaxDirectionalLights
static const UINT32 MaxDirectionalLights
Dir Lights.
Definition: GeometrySubpass.h:29
Fling::CameraInfoUbo
Definition: GeometrySubpass.h:46
Fling::GeometrySubpass::m_DescriptorSets
std::vector< VkDescriptorSet > m_DescriptorSets
Definition: GeometrySubpass.h:103
Fling::DeferredLightSettings
Settings for the max directional lights and max point lights.
Definition: GeometrySubpass.h:26
DirectionalLight.hpp
Fling::GeometrySubpass::m_Camera
const FirstPersonCamera * m_Camera
Definition: GeometrySubpass.h:97
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling
Definition: Engine.h:29
Fling::GeometrySubpass::m_LightingUboBuffers
std::vector< Buffer * > m_LightingUboBuffers
Definition: GeometrySubpass.h:104
Fling::ShaderProgramReflections::CreateDescriptorSets
void CreateDescriptorSets(MeshRenderer &t_MeshRend, Lighting &t_Lighting, VkDescriptorSetLayout t_DescriptorLayout)
Definition: ShaderProgramReflections.cpp:4
Fling::DeferredLightSettings::MaxPointLights
static const UINT32 MaxPointLights
Point Lights.
Definition: GeometrySubpass.h:32