Archived
1
Fork 0

Overhaul lighting and render debug menus

This commit is contained in:
Joshua Goins 2022-02-08 09:17:44 -05:00
parent 998c6f8bc2
commit aac9e673ad

View file

@ -54,66 +54,60 @@ void draw_asset() {
void draw_lighting() {
if(engine->get_scene() != nullptr) {
const auto& lights = engine->get_scene()->get_all<Light>();
ImGui::Text("Lights");
ImGui::Separator();
for(auto& [obj, light] : lights) {
ImGui::PushID(obj);
ImGui::TextDisabled("%s", engine->get_scene()->get(obj).name.c_str());
if(ImGui::CollapsingHeader("Lights")) {
for (auto&[obj, light]: lights) {
ImGui::PushID(obj);
auto& transform = engine->get_scene()->get<Transform>(obj);
ImGui::DragFloat3("Position", transform.position.ptr());
ImGui::DragFloat("Light Size", &light.size, 0.1f);
ImGui::Checkbox("Shadows enable", &light.enable_shadows);
ImGui::TextDisabled("%s", engine->get_scene()->get(obj).name.c_str());
ImGui::PopID();
auto& transform = engine->get_scene()->get<Transform>(obj);
ImGui::DragFloat3("Position", transform.position.ptr());
ImGui::DragFloat("Size", &light.size, 0.1f);
ImGui::Checkbox("Enable Shadows", &light.enable_shadows);
ImGui::Separator();
ImGui::PopID();
ImGui::Separator();
}
}
ImGui::Text("Environment");
ImGui::Separator();
if(ImGui::CollapsingHeader("Environment")) {
for(auto& [obj, probe] : engine->get_scene()->get_all<EnvironmentProbe>()) {
ImGui::PushID(obj);
for(auto& [obj, probe] : engine->get_scene()->get_all<EnvironmentProbe>()) {
ImGui::PushID(obj);
ImGui::TextDisabled("%s", engine->get_scene()->get(obj).name.c_str());
ImGui::TextDisabled("%s", engine->get_scene()->get(obj).name.c_str());
auto& transform = engine->get_scene()->get<Transform>(obj);
ImGui::DragFloat3("Position", transform.position.ptr());
ImGui::DragFloat3("Probe Size", probe.size.ptr(), 0.1f);
auto& transform = engine->get_scene()->get<Transform>(obj);
ImGui::DragFloat3("Position", transform.position.ptr());
ImGui::DragFloat3("Probe Size", probe.size.ptr(), 0.1f);
ImGui::PopID();
ImGui::PopID();
ImGui::Separator();
}
}
ImGui::Separator();
}
if(ImGui::CollapsingHeader("Materials")) {
for (auto& material: assetm->get_all<Material>()) {
ImGui::PushID(material);
ImGui::Text("Materials");
ImGui::Separator();
ImGui::TextDisabled("%s", material->path.c_str());
for(auto& material : assetm->get_all<Material>()) {
ImGui::PushID(material);
ImGui::DragFloat("Metallic", &material->metallic, 0.1f, 0.0f, 1.0f);
ImGui::DragFloat("Roughness", &material->roughness, 0.1f, 0.0f, 1.0f);
ImGui::TextDisabled("%s", material->path.c_str());
ImGui::PopID();
ImGui::DragFloat("Metallic", &material->metallic, 0.1f, 0.0f, 1.0f);
ImGui::DragFloat("Roughness", &material->roughness, 0.1f, 0.0f, 1.0f);
ImGui::Separator();
}
}
ImGui::PopID();
ImGui::Separator();
}
if(ImGui::Button("Reload shadows")) {
if(ImGui::Button("Reload shadows"))
engine->get_scene()->reset_shadows();
}
if(ImGui::Button("Reload probes")) {
if(ImGui::Button("Reload probes"))
engine->get_scene()->reset_environment();
}
} else {
ImGui::TextDisabled("No scene loaded.");
}
@ -162,21 +156,29 @@ void draw_renderer() {
ImGui::ComboEnum("Display Color Space", &render_options.display_color_space);
ImGui::ComboEnum("Tonemapping", &render_options.tonemapping);
ImGui::DragFloat("Exposure", &render_options.exposure, 0.1f);
ImGui::DragFloat("Min Luminance", &render_options.min_luminance);
ImGui::DragFloat("Max Luminance", &render_options.max_luminance);
ImGui::Checkbox("Enable DoF", &render_options.enable_depth_of_field);
ImGui::DragFloat("DoF Strength", &render_options.depth_of_field_strength);
if(ImGui::CollapsingHeader("Tonemapping")) {
ImGui::DragFloat("Exposure", &render_options.exposure, 0.1f);
ImGui::DragFloat("Min Luminance", &render_options.min_luminance);
ImGui::DragFloat("Max Luminance", &render_options.max_luminance);
}
if(ImGui::CollapsingHeader("Depth of Field")) {
ImGui::Checkbox("Enable DoF", &render_options.enable_depth_of_field);
ImGui::DragFloat("DoF Strength", &render_options.depth_of_field_strength);
}
bool should_recompile = false;
ImGui::Checkbox("Enable Dynamic Resolution", &render_options.dynamic_resolution);
float render_scale = render_options.render_scale;
if(ImGui::DragFloat("Render Scale", &render_scale, 0.1f, 1.0f, 0.1f) && render_scale > 0.0f) {
render_options.render_scale = render_scale;
engine->get_renderer()->recreate_all_render_targets();
if(ImGui::CollapsingHeader("Dynamic Resolution")) {
ImGui::Checkbox("Enable Dynamic Resolution", &render_options.dynamic_resolution);
float render_scale = render_options.render_scale;
if (ImGui::DragFloat("Render Scale", &render_scale, 0.1f, 1.0f, 0.1f)
&& render_scale > 0.0f) {
render_options.render_scale = render_scale;
engine->get_renderer()->recreate_all_render_targets();
}
}
if(ImGui::InputInt("Shadow Resolution", &render_options.shadow_resolution)) {