Skip to content
Snippets Groups Projects
Commit b0690281 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#82] Add UI toggle

parent 0d7127a5
No related branches found
No related tags found
1 merge request!70Resolve "Voxel cone tracing"
Pipeline #26030 passed
...@@ -363,6 +363,13 @@ int main(int argc, const char** argv) { ...@@ -363,6 +363,13 @@ int main(int argc, const char** argv) {
} }
}); });
bool renderUI = true;
window.e_key.add([&renderUI](int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_I && action == GLFW_PRESS) {
renderUI = !renderUI;
}
});
// tonemapping compute shader // tonemapping compute shader
vkcv::ShaderProgram tonemappingProgram; vkcv::ShaderProgram tonemappingProgram;
compiler.compile(vkcv::ShaderStage::COMPUTE, "resources/shaders/tonemapping.comp", compiler.compile(vkcv::ShaderStage::COMPUTE, "resources/shaders/tonemapping.comp",
...@@ -663,67 +670,68 @@ int main(int argc, const char** argv) { ...@@ -663,67 +670,68 @@ int main(int argc, const char** argv) {
// draw UI // draw UI
gui.beginGUI(); gui.beginGUI();
ImGui::Begin("Settings"); if (renderUI) {
ImGui::Begin("Settings");
ImGui::Checkbox("MSAA custom resolve", &msaaCustomResolve);
ImGui::Checkbox("MSAA custom resolve", &msaaCustomResolve);
ImGui::DragFloat2("Light angles", &lightAnglesDegree.x);
ImGui::ColorEdit3("Sun color", &lightColor.x); ImGui::DragFloat2("Light angles", &lightAnglesDegree.x);
ImGui::DragFloat("Sun strength", &lightStrength); ImGui::ColorEdit3("Sun color", &lightColor.x);
ImGui::DragFloat("Max shadow distance", &maxShadowDistance); ImGui::DragFloat("Sun strength", &lightStrength);
maxShadowDistance = std::max(maxShadowDistance, 1.f); ImGui::DragFloat("Max shadow distance", &maxShadowDistance);
maxShadowDistance = std::max(maxShadowDistance, 1.f);
ImGui::ColorEdit3("Sky color", &skySettings.color.x);
ImGui::DragFloat("Sky strength", &skySettings.strength, 0.1); ImGui::ColorEdit3("Sky color", &skySettings.color.x);
ImGui::DragFloat("Sky strength", &skySettings.strength, 0.1);
ImGui::Checkbox("Draw voxel visualisation", &renderVoxelVis);
ImGui::SliderInt("Visualisation mip", &voxelVisualisationMip, 0, 7); ImGui::Checkbox("Draw voxel visualisation", &renderVoxelVis);
ImGui::DragFloat("Voxelization extent", &voxelizationExtent, 1.f, 0.f); ImGui::SliderInt("Visualisation mip", &voxelVisualisationMip, 0, 7);
voxelizationExtent = std::max(voxelizationExtent, 1.f); ImGui::DragFloat("Voxelization extent", &voxelizationExtent, 1.f, 0.f);
voxelVisualisationMip = std::max(voxelVisualisationMip, 0); voxelizationExtent = std::max(voxelizationExtent, 1.f);
voxelVisualisationMip = std::max(voxelVisualisationMip, 0);
ImGui::ColorEdit3("Scattering color", &scatteringColor.x);
ImGui::DragFloat("Scattering density", &scatteringDensity, 0.0001); ImGui::ColorEdit3("Scattering color", &scatteringColor.x);
ImGui::ColorEdit3("Absorption color", &absorptionColor.x); ImGui::DragFloat("Scattering density", &scatteringDensity, 0.0001);
ImGui::DragFloat("Absorption density", &absorptionDensity, 0.0001); ImGui::ColorEdit3("Absorption color", &absorptionColor.x);
ImGui::DragFloat("Volumetric ambient", &volumetricAmbient, 0.002); ImGui::DragFloat("Absorption density", &absorptionDensity, 0.0001);
ImGui::DragFloat("Volumetric ambient", &volumetricAmbient, 0.002);
if (ImGui::Button("Reload forward pass")) {
if (ImGui::Button("Reload forward pass")) {
vkcv::ShaderProgram newForwardProgram;
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/shader.vert"), vkcv::ShaderProgram newForwardProgram;
[&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/shader.vert"),
newForwardProgram.addShader(shaderStage, path); [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
}); newForwardProgram.addShader(shaderStage, path);
compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/shader.frag"), });
[&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/shader.frag"),
newForwardProgram.addShader(shaderStage, path); [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
}); newForwardProgram.addShader(shaderStage, path);
forwardPipelineConfig.m_ShaderProgram = newForwardProgram; });
vkcv::PipelineHandle newPipeline = core.createGraphicsPipeline(forwardPipelineConfig); forwardPipelineConfig.m_ShaderProgram = newForwardProgram;
vkcv::PipelineHandle newPipeline = core.createGraphicsPipeline(forwardPipelineConfig);
if (newPipeline) {
forwardPipeline = newPipeline; if (newPipeline) {
forwardPipeline = newPipeline;
}
} }
} if (ImGui::Button("Reload tonemapping")) {
if (ImGui::Button("Reload tonemapping")) {
vkcv::ShaderProgram newProgram;
vkcv::ShaderProgram newProgram; compiler.compile(vkcv::ShaderStage::COMPUTE, std::filesystem::path("resources/shaders/tonemapping.comp"),
compiler.compile(vkcv::ShaderStage::COMPUTE, std::filesystem::path("resources/shaders/tonemapping.comp"), [&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
[&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { newProgram.addShader(shaderStage, path);
newProgram.addShader(shaderStage, path); });
}); vkcv::PipelineHandle newPipeline = core.createComputePipeline(
vkcv::PipelineHandle newPipeline = core.createComputePipeline( newProgram,
newProgram, { core.getDescriptorSet(tonemappingDescriptorSet).layout });
{ core.getDescriptorSet(tonemappingDescriptorSet).layout });
if (newPipeline) {
if (newPipeline) { tonemappingPipeline = newPipeline;
tonemappingPipeline = newPipeline; }
} }
ImGui::End();
} }
ImGui::End();
gui.endGUI(); gui.endGUI();
core.endFrame(); core.endFrame();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment