Commit 739edf69 authored by Johannes Braun's avatar Johannes Braun
Browse files

Some imgui changes.

parent 00579b3c
...@@ -4,7 +4,7 @@ Size=353,64 ...@@ -4,7 +4,7 @@ Size=353,64
Collapsed=0 Collapsed=0
[Scene] [Scene]
Pos=0,67 Pos=2,70
Size=352,837 Size=352,837
Collapsed=0 Collapsed=0
......
<linespace version="1.0"> <linespace version="1.0">
<item name="subdivisions" value="20"/> <item name="subdivisions" value="10"/>
<item name="grid-subdivisions" value="10"/> <item name="grid-subdivisions" value="10"/>
<item name="radial-subdivision" value="50"/> <item name="radial-subdivision" value="50"/>
<item name="generator" value="gpu"/> <item name="generator" value="gpu"/>
......
...@@ -31,5 +31,5 @@ void main() ...@@ -31,5 +31,5 @@ void main()
vec2 random = settings.u_random_subpixel ? vec2(0, 0) : rand2D(random_seed + id, target_size.x*target_size.y); vec2 random = settings.u_random_subpixel ? vec2(0, 0) : rand2D(random_seed + id, target_size.x*target_size.y);
traces_data[id].ray = u_camera.getRayFromPixel(vec2(gl_GlobalInvocationID.xy), random, vec2(target_size)); traces_data[id].ray = u_camera.getRayFromPixel(vec2(gl_GlobalInvocationID.xy), random, vec2(target_size));
traces_data[id].hit.invalidate(); traces_data[id].hit.invalidate();
traces_data[id].ray.nearestIntersection(traces_data[id].hit, false); traces_data[id].ray.nearestIntersection(traces_data[id].hit, true);
} }
...@@ -304,12 +304,9 @@ void drawSceneWindow() ...@@ -304,12 +304,9 @@ void drawSceneWindow()
} }
} }
break; break;
case 1: // Transform case 1: // Transform
// Pos
ImGui::DragFloat3("Position", reinterpret_cast<float*>(&(selected_node->transform.position)), 0.01f); ImGui::DragFloat3("Position", reinterpret_cast<float*>(&(selected_node->transform.position)), 0.01f);
// Rotation
ImGui::QuaternionGizmo("Rotation", *reinterpret_cast<ImQuat*>(&selected_node->transform.rotation)); ImGui::QuaternionGizmo("Rotation", *reinterpret_cast<ImQuat*>(&selected_node->transform.rotation));
// Scale
ImGui::DragFloat3("Scale", reinterpret_cast<float*>(&(selected_node->transform.scale)), 0.01f); ImGui::DragFloat3("Scale", reinterpret_cast<float*>(&(selected_node->transform.scale)), 0.01f);
break; break;
case 2: // Components (if available) case 2: // Components (if available)
...@@ -318,8 +315,10 @@ void drawSceneWindow() ...@@ -318,8 +315,10 @@ void drawSceneWindow()
selected_node->iterateComponentsStable([](core::SceneComponent& component) selected_node->iterateComponentsStable([](core::SceneComponent& component)
{ {
ImGui::PushID(("component-" + std::to_string(component.id())).c_str()); ImGui::PushID(("component-" + std::to_string(component.id())).c_str());
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
if (ImGui::CollapsingHeader(component.typeName().c_str())) if (ImGui::CollapsingHeader(component.typeName().c_str()))
{ {
ImGui::PopStyleVar();
component.debugGui(); component.debugGui();
if (ImGui::AntiFeatureButton("Delete", ImVec2(ImGui::GetContentRegionAvailWidth(), 24))) if (ImGui::AntiFeatureButton("Delete", ImVec2(ImGui::GetContentRegionAvailWidth(), 24)))
{ {
...@@ -343,6 +342,11 @@ void drawSceneWindow() ...@@ -343,6 +342,11 @@ void drawSceneWindow()
ImGui::EndPopup(); ImGui::EndPopup();
} }
} }
else
{
ImGui::PopStyleVar();
}
ImGui::PopID(); ImGui::PopID();
ImGui::Spacing(); ImGui::Spacing();
...@@ -460,23 +464,20 @@ void drawSettingsWindow() ...@@ -460,23 +464,20 @@ void drawSettingsWindow()
ImGui::Spacing(); ImGui::Spacing();
const std::array<std::string, 3> names{ "Scene Settings", "Sampling and Performance" , "Linespace Thresholds" };
static int curr = 0; static int curr = 0;
ImGui::Tabs(names, curr); ImGui::Tabs(std::array<std::string, 3>{ "Scene Settings", "Sampling and Performance", "Linespace Thresholds" }, curr);
switch (curr) switch (curr)
{ {
case 0: case 0:
{ {
ImGui::TextWrapped("By default, a transformation or mesh update will trigger a pathtracer sample count reset. If you want to limit this to explicit settings changes and camera movements, uncheck the following option."); ImGui::TextWrapped("By default, a transformation or mesh update will trigger a pathtracer sample count reset. If you want to limit this to explicit settings changes and camera movements, uncheck the following option.");
bool collector_active = pathtracer->collector()->isActive(); if (bool collector_active = pathtracer->collector()->isActive(); ImGui::Checkbox("Reset on scene update", &collector_active))
if (ImGui::Checkbox("Reset on scene update", &collector_active))
pathtracer->collector()->setActive(collector_active); pathtracer->collector()->setActive(collector_active);
ImGui::Spacing(); ImGui::Spacing();
auto format = static_cast<int>(pathtracer->collector()->getSceneFormat()); if (auto format = static_cast<int>(pathtracer->collector()->getSceneFormat());
if (ImGui::Combo("", &format, { "Default", "Global BVH" }) && format != static_cast<int>(pathtracer->collector()->getSceneFormat())) ImGui::Combo("", &format, { "Default", "Global BVH" }) && format != static_cast<int>(pathtracer->collector()->getSceneFormat()))
{ {
pathtracer->collector()->setSceneFormat(static_cast<raytrace::SceneFormat>(format)); pathtracer->collector()->setSceneFormat(static_cast<raytrace::SceneFormat>(format));
} }
...@@ -486,11 +487,9 @@ void drawSettingsWindow() ...@@ -486,11 +487,9 @@ void drawSettingsWindow()
{ {
ImGui::BeginNamedGroup("Ray Generator"); ImGui::BeginNamedGroup("Ray Generator");
{ {
int raygenstate = static_cast<int>(pathtracer->getRayGenerator());
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()); ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
if (ImGui::Combo("", &raygenstate, { "Trace [default]", "OpenGL GBuffer" })) { if (int raygenstate = static_cast<int>(pathtracer->getRayGenerator()); ImGui::Combo("", &raygenstate, { "Trace [default]", "OpenGL GBuffer" }))
pathtracer->setRayGenerator(static_cast<raytrace::RayGenType>(raygenstate)); pathtracer->setRayGenerator(static_cast<raytrace::RayGenType>(raygenstate));
}
ImGui::PopItemWidth(); ImGui::PopItemWidth();
} }
ImGui::EndNamedGroup(); ImGui::EndNamedGroup();
...@@ -505,12 +504,11 @@ void drawSettingsWindow() ...@@ -505,12 +504,11 @@ void drawSettingsWindow()
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::Spacing(); ImGui::Spacing();
int max_samples = pathtracer->getSamplesMax();
if (ImGui::DragInt("Maximum", &max_samples, 10, 1, 100000)) if (int max_samples = pathtracer->getSamplesMax(); ImGui::DragInt("Maximum", &max_samples, 10, 1, 100000))
pathtracer->setSamplesMax(max_samples); pathtracer->setSamplesMax(max_samples);
int spfr = pathtracer->getSamplesPerFrame(); if (int spfr = pathtracer->getSamplesPerFrame(); ImGui::DragInt("per frame", &spfr, 0.1f, 1, 10))
if (ImGui::DragInt("per frame", &spfr, 0.1f, 1, 10))
pathtracer->setSamplesPerFrame(spfr); pathtracer->setSamplesPerFrame(spfr);
} }
ImGui::EndNamedGroup(); ImGui::EndNamedGroup();
...@@ -520,8 +518,7 @@ void drawSettingsWindow() ...@@ -520,8 +518,7 @@ void drawSettingsWindow()
ImGui::BeginNamedGroup("Bounces"); ImGui::BeginNamedGroup("Bounces");
ImGui::TextWrapped("The global bounce limit clamps down all effect-dependant bounce limits to a unified maximum value."); ImGui::TextWrapped("The global bounce limit clamps down all effect-dependant bounce limits to a unified maximum value.");
{ {
int bounces = pathtracer->getBounceCount(); if (int bounces = pathtracer->getBounceCount(); ImGui::DragInt("Global Limit", &bounces, 0.1f, 0, 255))
if (ImGui::DragInt("Global Limit", &bounces, 0.1f, 0, 255))
pathtracer->setBounceCount(bounces); pathtracer->setBounceCount(bounces);
ImGui::Spacing(); ImGui::Spacing();
...@@ -531,8 +528,7 @@ void drawSettingsWindow() ...@@ -531,8 +528,7 @@ void drawSettingsWindow()
// Let's keep this function locally near to the only place it's being used. // Let's keep this function locally near to the only place it's being used.
static auto effectBounces = [](const std::string &label, raytrace::Effect effect) static auto effectBounces = [](const std::string &label, raytrace::Effect effect)
{ {
int val = pathtracer->getBounceThreshold(effect); if (int val = pathtracer->getBounceThreshold(effect); ImGui::DragInt(label.c_str(), &val, 0.1f, 0, 255))
if (ImGui::DragInt(label.c_str(), &val, 0.1f, 0, 255))
pathtracer->setBounceThreshold(effect, static_cast<uint8_t>(val)); pathtracer->setBounceThreshold(effect, static_cast<uint8_t>(val));
}; };
...@@ -547,12 +543,10 @@ void drawSettingsWindow() ...@@ -547,12 +543,10 @@ void drawSettingsWindow()
ImGui::TextWrapped("The direct clamp setting will lead to the primary ray result color being clamped down to a set maximum. That means each color component will be clamped. The same applies to the \"clamp indirect\" setting for non-primary bounces."); ImGui::TextWrapped("The direct clamp setting will lead to the primary ray result color being clamped down to a set maximum. That means each color component will be clamped. The same applies to the \"clamp indirect\" setting for non-primary bounces.");
{ {
float clamp_direct = pathtracer->getClampDirect(); if (float clamp_direct = pathtracer->getClampDirect(); ImGui::DragFloat("Clamp Direct", &clamp_direct, 0.1f, 0.0f, 100.f))
if (ImGui::DragFloat("Clamp Direct", &clamp_direct, 0.1f, 0.0f, 100.f))
pathtracer->setClampDirect(clamp_direct); pathtracer->setClampDirect(clamp_direct);
float clamp_indirect = pathtracer->getClampIndirect(); if (float clamp_indirect = pathtracer->getClampIndirect(); ImGui::DragFloat("Clamp Indirect", &clamp_indirect, 0.1f, 0.0f, 100.f))
if (ImGui::DragFloat("Clamp Indirect", &clamp_indirect, 0.1f, 0.0f, 100.f))
pathtracer->setClampIndirect(clamp_indirect); pathtracer->setClampIndirect(clamp_indirect);
} }
} }
...@@ -562,20 +556,17 @@ void drawSettingsWindow() ...@@ -562,20 +556,17 @@ void drawSettingsWindow()
ImGui::Title("PDF Thresholds"); ImGui::Title("PDF Thresholds");
ImGui::TextWrapped("The following threshold values will determine as of which accumulated PDF value the Line Space should be used instead of the BVH."); ImGui::TextWrapped("The following threshold values will determine as of which accumulated PDF value the Line Space should be used instead of the BVH.");
{ {
float acc = pathtracer->getLinespaceAccuracy(); if (float acc = pathtracer->getLinespaceAccuracy(); ImGui::DragFloat("Direct", &acc, 0.001f, 0.0f, 1.f))
if (ImGui::DragFloat("Direct", &acc, 0.001f, 0.0f, 1.f))
pathtracer->setLinespaceAccuracy(acc); pathtracer->setLinespaceAccuracy(acc);
float shd = pathtracer->getLinespaceShadow(); if (float shd = pathtracer->getLinespaceShadow(); ImGui::DragFloat("Shadow", &shd, 0.001f, 0.0f, 1.f))
if (ImGui::DragFloat("Shadow", &shd, 0.001f, 0.0f, 1.f))
pathtracer->setLinespaceShadow(shd); pathtracer->setLinespaceShadow(shd);
} }
ImGui::Title("Distance Threshold"); ImGui::Title("Distance Threshold");
ImGui::TextWrapped("Works like a level of detail slider. This is the maximum path length with which the BVH should be used."); ImGui::TextWrapped("Works like a level of detail slider. This is the maximum path length with which the BVH should be used.");
{ {
float dt = pathtracer->getLinespaceDistance(); if (float dt = pathtracer->getLinespaceDistance(); ImGui::DragFloat("Distance", &dt, 0.1f, 0.0f, 10000.f))
if (ImGui::DragFloat("Distance", &dt, 0.1f, 0.0f, 10000.f))
pathtracer->setLinespaceDistance(dt); pathtracer->setLinespaceDistance(dt);
} }
...@@ -585,8 +576,7 @@ void drawSettingsWindow() ...@@ -585,8 +576,7 @@ void drawSettingsWindow()
// Let's keep this function locally near to the only place it's being used. // Let's keep this function locally near to the only place it's being used.
static auto bounceControl = [](const std::string &label, raytrace::Effect effect) static auto bounceControl = [](const std::string &label, raytrace::Effect effect)
{ {
int val = pathtracer->getLinespaceBounces(effect); if (int val = pathtracer->getLinespaceBounces(effect); ImGui::DragInt(label.c_str(), &val, 0.1f, 0, pathtracer->getLinespaceBounces(effect)))
if (ImGui::DragInt(label.c_str(), &val, 0.1f, 0, pathtracer->getLinespaceBounces(effect)))
pathtracer->setLinespaceBounces(effect, static_cast<uint8_t>(val)); pathtracer->setLinespaceBounces(effect, static_cast<uint8_t>(val));
}; };
...@@ -611,8 +601,7 @@ void drawSettingsWindow() ...@@ -611,8 +601,7 @@ void drawSettingsWindow()
{ {
ImGui::Title("General Settings"); ImGui::Title("General Settings");
auto vsync = static_cast<int>(core::Context::current().window().getVSync()); if (auto vsync = static_cast<int>(core::Context::current().window().getVSync()); ImGui::Combo("VSync", &vsync, { "None", "60 FPS", "30 FPS", "20 FPS" }))
if (ImGui::Combo("VSync", &vsync, { "None", "60 FPS", "30 FPS", "20 FPS" }))
core::Context::current().window().setVSync(static_cast<VSync>(vsync)); core::Context::current().window().setVSync(static_cast<VSync>(vsync));
ImGui::Spacing(); ImGui::Spacing();
......
...@@ -299,7 +299,7 @@ namespace ImGui { ...@@ -299,7 +299,7 @@ namespace ImGui {
style->Colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f); style->Colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f);
style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.24f, 0.23f, 0.29f, 1.00f); style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.24f, 0.23f, 0.29f, 1.00f);
style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.07f, 0.75f); style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.07f, 0.25f);
style->Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); style->Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f);
style->Colors[ImGuiCol_PopupBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); style->Colors[ImGuiCol_PopupBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f);
style->Colors[ImGuiCol_Border] = ImVec4(0.80f, 0.80f, 0.83f, 0.88f); style->Colors[ImGuiCol_Border] = ImVec4(0.80f, 0.80f, 0.83f, 0.88f);
......
...@@ -269,7 +269,7 @@ namespace ImGui { ...@@ -269,7 +269,7 @@ namespace ImGui {
auto old_bg = ImGui::GetStyle().Colors[ImGuiCol_Header]; auto old_bg = ImGui::GetStyle().Colors[ImGuiCol_Header];
if(is_selected) ImGui::GetStyle().Colors[ImGuiCol_Header] = ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]; if(is_selected) ImGui::GetStyle().Colors[ImGuiCol_Header] = ImGui::GetStyle().Colors[ImGuiCol_ButtonActive];
bool retval = ImGui::TreeNodeEx(label, ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_Framed | flags); bool retval = ImGui::TreeNodeEx(label, ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_Framed | flags);
ImGui::GetStyle().Colors[ImGuiCol_Header] = old_bg; ImGui::GetStyle().Colors[ImGuiCol_Header] = old_bg;
ImGui::PopStyleVar(); ImGui::PopStyleVar();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment