SpiecsEngine
 
Loading...
Searching...
No Matches
ImguiGBufferVisualizer.cpp
Go to the documentation of this file.
1/**
2* @file ImguiGBufferVisualizer.cpp.
3* @brief The ImguiGizmos Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9
10#include "Render/Vulkan/VulkanRenderBackend.h"
11
12namespace Spices {
13
15 const std::string& panelName ,
16 FrameInfo& frameInfo
17 )
18 : ImguiSlate(panelName, frameInfo)
19 {
21
23 }
24
26 {
28
29 if (!m_IsSlateOn) return;
30
31 /**
32 * @brief Begin render GBuffer Visualizer.
33 */
34 Begin(m_PanelName.c_str());
35
36 ImVec2 size = { m_Width , m_Height };
37
38 /**
39 * @brief Render SceneColor.
40 */
41 {
42 SPICES_PROFILE_ZONEN("Render SceneColor");
43
44 ImGui::Text("SceneColor");
45 ImGui::Image(m_GBufferID.SceneColorID, size);
46 ImGui::Separator();
47 }
48
49 /**
50 * @brief Render Albedo.
51 */
52 {
53 SPICES_PROFILE_ZONEN("Render Albedo");
54
55 ImGui::Text("Albedo");
56 ImGui::Image(m_GBufferID.AlbedoID, size);
57 ImGui::Separator();
58 }
59
60 /**
61 * @brief Render Normal.
62 */
63 {
64 SPICES_PROFILE_ZONEN("Render Normal");
65
66 ImGui::Text("Normal");
67 ImGui::Image(m_GBufferID.NormalID, size);
68 ImGui::Separator();
69 }
70
71 /**
72 * @brief Render Roughness.
73 */
74 {
75 SPICES_PROFILE_ZONEN("Render Roughness");
76
77 ImGui::Text("Roughness");
78 ImGui::Image(m_GBufferID.RoughnessID, size);
79 ImGui::Separator();
80 }
81
82 /**
83 * @brief Render Metallic.
84 */
85 {
86 SPICES_PROFILE_ZONEN("Render Metallic");
87
88 ImGui::Text("Metallic");
89 ImGui::Image(m_GBufferID.MetallicID, size);
90 ImGui::Separator();
91 }
92
93 /**
94 * @brief Render Position.
95 */
96 {
97 SPICES_PROFILE_ZONEN("Render Position");
98
99 ImGui::Text("Position");
100 ImGui::Image(m_GBufferID.PositionID, size);
101 ImGui::Separator();
102 }
103
104 /**
105 * @brief End render GBuffer Visualizer.
106 */
107 End();
108
109 }
110
112 {
114
115 /**
116 * @brief Instance a EventDispatcher.
117 */
118 EventDispatcher dispatcher(event);
119
120 /**
121 * @brief Dispatch SlateResizeEvent to ImguiGBufferVisualizer::OnSlateResized.
122 */
124 }
125
127 {
129
130 /**
131 * @brief Free old DescriptorSet.
132 */
133 m_GBufferID.Free();
134
135 m_Width = 500;
136 m_Height = m_Width * event.GetHeight() / static_cast<float>(event.GetWidth());
137
138 /**
139 * @rief Re Query GBufferID.
140 */
142
143 /**
144 * @brief Do not block the event.
145 */
146 return false;
147 }
148
150 {
152
153 const VkDescriptorImageInfo* sceneColorInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "SceneColor" });
154 const VkDescriptorImageInfo* albedoInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "Albedo" });
155 const VkDescriptorImageInfo* normalInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "Normal" });
156 const VkDescriptorImageInfo* roughnessInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "Roughness" });
157 const VkDescriptorImageInfo* metallicInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "Metallic" });
158 const VkDescriptorImageInfo* positionInfo = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ "Position" });
159
160 m_GBufferID.SceneColorID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(sceneColorInfo->sampler , sceneColorInfo->imageView , sceneColorInfo->imageLayout ));
161 m_GBufferID.AlbedoID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(albedoInfo->sampler , albedoInfo->imageView , albedoInfo->imageLayout ));
162 m_GBufferID.NormalID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(normalInfo->sampler , normalInfo->imageView , normalInfo->imageLayout ));
163 m_GBufferID.RoughnessID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(roughnessInfo->sampler , roughnessInfo->imageView , roughnessInfo->imageLayout ));
164 m_GBufferID.MetallicID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(metallicInfo->sampler , metallicInfo->imageView , metallicInfo->imageLayout ));
165 m_GBufferID.PositionID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(positionInfo->sampler , positionInfo->imageView , positionInfo->imageLayout ));
166 }
167}
#define BIND_EVENT_FN(x)
Bind Event.
Definition Event.h:88
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
EventDispatcher(Event &event)
Constructor Function.
Definition Event.h:172
This Class store a Specific Event type first and Dispatch a event handle function to it.
Definition Event.h:156
This Class is the basic Event Class. Inherit from it and create specific event class.
Definition Event.h:96
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
void QueryGBufferID()
Query GBufferID from RendererResourcePool.
bool OnSlateResized(SlateResizeEvent &event)
Event Dispatcher target. Registy on Slate(Viewport) Resized.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
ImguiGBufferVisualizer(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
void End()
End a slate.
ImguiSlate(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function. Init with Slate's name.
Definition ImguiUtils.h:35
This Class defines the basic behaves of specific slate. When we add an new Slate, we need inherit fro...
Definition ImguiUtils.h:27
const uint32_t & GetHeight() const
Get New Viewport Height.
Definition SlateEvent.h:46
const uint32_t & GetWidth() const
Get New Viewport Width.
Definition SlateEvent.h:40
This Class is inherited from Event Class. Called by Viewport Resize.
Definition SlateEvent.h:18