4#include "imgui/imgui.h"
5#include "imgui_widgets/utils.h"
33 auto&
scene = ec.get_scene();
42 auto&
scene = ec.get_scene();
49 if(!is_visible_ && !is_visible_force_)
54 auto&
scene = ec.get_scene();
60 is_visible_force_ =
false;
68 if(ImGui::Begin(
name,
nullptr, ImGuiWindowFlags_MenuBar))
75 allowed &= ImGui::IsWindowFocused();
84 input.manager.set_is_input_allowed(allowed);
89 is_visible_ = visible;
94 is_visible_force_ = visible;
99 ImVec2 viewport = avail_size;
103 viewport = avail_size;
108 viewport.x =
static_cast<float>(res.
width);
109 viewport.y =
static_cast<float>(res.
height);
111 else if(res.
aspect > 0.0f)
113 float avail_aspect = avail_size.x / std::max(avail_size.y, 1.0f);
114 if(avail_aspect > res.
aspect)
116 viewport.y = avail_size.y;
117 viewport.x = avail_size.y * res.
aspect;
121 viewport.x = avail_size.x;
122 viewport.y = avail_size.x / res.
aspect;
125 camera_comp.
set_viewport_size({
static_cast<std::uint32_t
>(viewport.x),
static_cast<std::uint32_t
>(viewport.y)});
138 auto size = ImGui::GetContentRegionAvail();
140 if(settings.resolution.resolutions.empty())
145 current_resolution_index_ = settings.resolution.get_current_resolution_index();
148 bool rendered =
false;
149 ec.get_scene().registry->view<camera_component>().each(
150 [&](
auto e,
auto&& camera_comp)
152 apply_resolution_to_camera(camera_comp, resolutions[std::clamp(current_resolution_index_, 0, (
int)resolutions.size()-1)],
size);
154 const auto& camera = camera_comp.
get_camera();
156 const auto& obuffer = rview.fbo_safe_get(
"OBUFFER");
160 auto tex = obuffer->get_texture(0);
161 auto tex_size = obuffer->get_size();
162 ImVec2 tex_size_v(tex_size.width, tex_size.height);
163 ImGui::ImageWithAspect(
ImGui::ToId(tex), tex_size_v,
size, ImVec2(0.5f, 0.5f));
165 ImVec2 min = ImGui::GetItemRectMin();
166 ImVec2 max = ImGui::GetItemRectMax();
171 work_zone.w = max.x - min.x;
172 work_zone.h = max.y - min.y;
175 ctx.
get_cached<input_system>().manager.set_work_zone(work_zone);
176 ctx.
get_cached<input_system>().manager.set_reference_size({tex_size_v.x, tex_size_v.y});
180 ImVec2 padding(2.0f, 2.0f);
181 ImGui::RenderFocusFrame(ImGui::GetItemRectMin() - padding, ImGui::GetItemRectMax() + padding);
185 camera_comp.
get_pipeline_data().get_pipeline()->set_debug_pass(visualize_passes_);
191 static const auto text =
"No cameras rendering";
192 ImGui::SetCursorPosY(
size.y * 0.5f);
193 ImGui::AlignedItem(0.5f,
195 ImGui::CalcTextSize(text).x,
198 ImGui::TextUnformatted(text);
207 auto& settings = pm.get_settings();
208 if(settings.resolution.resolutions.empty())
212 const auto& resolutions = settings.resolution.resolutions;
213 current_resolution_index_ = settings.resolution.get_current_resolution_index();
214 if(ImGui::BeginMenuBar())
218 ImGui::RadioButton(
"Full", &visualize_passes_, -1);
219 ImGui::RadioButton(
"Base Color", &visualize_passes_, 0);
220 ImGui::RadioButton(
"Diffuse Color", &visualize_passes_, 1);
221 ImGui::RadioButton(
"Specular Color", &visualize_passes_, 2);
222 ImGui::RadioButton(
"Indirect Specular Color", &visualize_passes_, 3);
223 ImGui::RadioButton(
"Ambient Occlusion", &visualize_passes_, 4);
224 ImGui::RadioButton(
"Normals (World Space)", &visualize_passes_, 5);
225 ImGui::RadioButton(
"Roughness", &visualize_passes_, 6);
226 ImGui::RadioButton(
"Metalness", &visualize_passes_, 7);
227 ImGui::RadioButton(
"Emissive Color", &visualize_passes_, 8);
228 ImGui::RadioButton(
"Subsurface Color", &visualize_passes_, 9);
229 ImGui::RadioButton(
"Depth", &visualize_passes_, 10);
232 ImGui::SetItemTooltipEx(
"%s",
"Visualize Render Passes");
233 if(ImGui::BeginMenu(fmt::format(
"{} {}", resolutions[std::clamp(current_resolution_index_, 0, (
int)resolutions.size()-1)].name,
ICON_MDI_ARROW_DOWN_BOLD).c_str()))
235 for(
int i = 0;
i < (int)resolutions.size(); ++
i)
237 if(ImGui::RadioButton(resolutions[i].
name.c_str(), ¤t_resolution_index_, i))
239 settings.resolution.set_current_resolution_index(i);
240 pm.save_project_settings(ctx);
244 if(ImGui::MenuItem(
"Edit ...",
"",
false))
246 ctx.
get_cached<hub>().open_project_settings(ctx,
"Resolution");
250 ImGui::SetItemTooltipEx(
"%s",
"Resolution Presets");
253 auto& io = ImGui::GetIO();
255 auto fps_size = ImGui::CalcTextSize(fmt::format(
"{:.1f}", io.Framerate).c_str()).x;
260 ImGui::AlignedItem(1.0f,
261 ImGui::GetContentRegionAvail().
x,
266 ImGui::Text(
"%.1f", io.Framerate);
Class that contains core camera data, used for rendering and other purposes.
auto get_pipeline_data() -> pipeline_camera &
void set_viewport_size(const usize32_t &size)
Sets the viewport size.
auto get_render_view() -> gfx::render_view &
Gets the render view.
auto get_camera() -> camera &
Gets the camera object.
void deinit(rtti::context &ctx)
void init(rtti::context &ctx)
void on_frame_update(rtti::context &ctx, delta_t dt)
void on_frame_ui_render(rtti::context &ctx, const char *name)
void set_visible(bool visible)
void on_frame_render(rtti::context &ctx, delta_t dt)
void set_visible_force(bool visible)
void on_frame_before_render(rtti::context &ctx, delta_t dt)
Base class for different rendering paths in the ACE framework.
void on_frame_update(scene &scn, delta_t dt)
Prepares the scene for rendering.
void on_frame_before_render(scene &scn, delta_t dt)
auto render_scene(scene &scn, delta_t dt) -> gfx::frame_buffer::ptr
Renders the scene and returns the frame buffer.
std::chrono::duration< float > delta_t
#define ICON_MDI_ARROW_DOWN_BOLD
#define ICON_MDI_DRAWING_BOX
void PushFont(Font::Enum _font)
ImTextureID ToId(gfx::texture_handle _handle, uint8_t _mip=0, uint8_t _flags=IMGUI_FLAGS_ALPHA_BLEND)
Manages the entity-component-system (ECS) operations for the ACE framework.
Represents a scene in the ACE framework, managing entities and their relationships.
std::vector< resolution > resolutions
struct unravel::settings::resolution_settings resolution
System responsible for managing user interface components and rendering.