Commit ff7b807c authored by MURRAY David's avatar MURRAY David

added option to save all config + data

parent 2e805556
Pipeline #106496 skipped with stage
......@@ -37,6 +37,10 @@ ImGUI_shader::ImGUI_shader(mrf::gui::fb::Loger::LEVEL const & logging_level) :
_variance_samples = 128;
_variance = nullptr;
_time = nullptr;
_save_all = false;
_prev_alpha = 0.f;
_samples_done = 0;
}
ImGUI_shader::~ImGUI_shader()
......@@ -139,6 +143,11 @@ void ImGUI_shader::customUI(ImGUI::UI_MODE mode)
_render_on_pause = true;
ImGui::OpenPopup("Variance");
}
else if (ImGui::Button("Save all variance config ") && !_log_variance)
{
_save_all = true;
_variance_samples = 4096;
}
variancePopUp();
if (_log_variance)
......@@ -192,34 +201,55 @@ void ImGUI_shader::display()
_time[_frame] = _elapsed_time;
if (_frame == _variance_samples - 1)
{
saveVarianceAtPicked();
std::string filename, dir, config;
mrf::util::StringParsing::getDirectory(_image_output_file.c_str(), dir);
saveConfig();
if (!_save_all)
{
_log_variance = false;
_log_time = false;
}
}
}
_current_mode = UI_MODE::DISPLAY;
config = "samples" + std::to_string(_variance_samples);
if (_use_sample_balancing)
_frame++;
if (_log_variance)
++_samples_done;
if (_save_all)
{
_log_time = true;
//_picking_pos[0] = 123;
//_picking_pos[1] = 71;
if (_samples_done%_variance_samples == 0)
{
if (_samples_done == 0)
{
config = config + "_start" + std::to_string(_renderer->getStartAlpha());
config = config + "_" + std::to_string(_renderer->getSamplesAlpha()) + "x" + std::to_string(_renderer->getAlphaPasses());
if (_reset_on_iteration)
config = config + "_withReset";
_use_sample_balancing = false;
}
else
config = config + "_noBalance";
{
_use_sample_balancing = true;
_prev_alpha = 0.5f * (int)(((_samples_done - _variance_samples) / _variance_samples) % 3);
_renderer->setStartAlpha(_prev_alpha);
filename = dir + "variance_" + config;
_renderer->saveImage(filename + ".png", "variance_buffer");
filename = dir + "radiance_" + config;
_renderer->saveImage(filename + ".exr", "output_buffer");
if (((_samples_done - _variance_samples) / _variance_samples) < 3)
_reset_on_iteration = true;
else
_reset_on_iteration = false;
_renderer->setResetOnIteration(_reset_on_iteration);
}
_renderer->setBalancing(_use_sample_balancing);
activateVarianceLog();
_camera_changed = true;
}
if ((_samples_done-1) / _variance_samples == 7)
{
_log_variance = false;
_log_time = false;
}
}
_current_mode = UI_MODE::DISPLAY;
_frame++;
}
void ImGUI_shader::render(Shader* prg, bool use_tex)
......@@ -446,7 +476,7 @@ void ImGUI_shader::unbindSSBO()
}
}
void ImGUI_shader::saveVarianceAtPicked()
void ImGUI_shader::saveVarianceAtPicked(std::string filename)
{
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
bindSSBO();
......@@ -461,13 +491,6 @@ void ImGUI_shader::saveVarianceAtPicked()
unbindSSBO();
std::ofstream file;
std::string filename;
filename = _image_output_file.substr(0, _image_output_file.size() - 4) + "_variance_" + std::to_string(_variance_samples);
if(_use_sample_balancing)
filename = filename + "_start" + std::to_string(_renderer->getStartAlpha()) + ".txt";
else
filename = filename + "_noBalance.txt";
file.open(filename, std::ios::out);
for (int i = 0; i < _variance_samples; ++i)
......@@ -534,3 +557,27 @@ void ImGUI_shader::variancePopUp()
}
}
}
void ImGUI_shader::saveConfig()
{
std::string filename, dir, config;
mrf::util::StringParsing::getDirectory(_image_output_file.c_str(), dir);
config = "samples" + std::to_string(_variance_samples) + "_mpl" + std::to_string(_renderer->getMaxPathLength());
if (_use_sample_balancing)
{
config = config + "_start" + std::to_string(_renderer->getStartAlpha());
config = config + "_" + std::to_string(_renderer->getSamplesAlpha()) + "x" + std::to_string(_renderer->getAlphaPasses());
if (_reset_on_iteration)
config = config + "_withReset";
}
else
config = config + "_noBalance";
filename = dir + "variance_" + config;
_renderer->saveImage(filename + ".png", "variance_buffer");
saveVarianceAtPicked(filename + ".txt");
filename = dir + "radiance_" + config;
_renderer->saveImage(filename + ".exr", "output_buffer");
}
......@@ -52,7 +52,7 @@ private:
void activateVarianceLog();
void stopVarianceLog();
void saveVarianceAtPicked();
void saveVarianceAtPicked(std::string filename);
void addVarianceItem(int iteration, float log_time = 0.f);
void initSSBO();
......@@ -61,6 +61,7 @@ private:
void unbindSSBO();
void variancePopUp();
void saveConfig();
enum VisuMode {
RADIANCE_ADJUSTED,
......@@ -85,4 +86,8 @@ private:
int _variance_samples;
float* _variance;
float* _time;
bool _save_all;
float _prev_alpha;
int _samples_done;
};
......@@ -112,7 +112,7 @@ void GUI::createContext(int w, int h)
}
glfwMakeContextCurrent(_window);
glfwSwapInterval(1);// ~V-sync
glfwSwapInterval(0);// ~V-sync
std::cout << "GL version: " << glGetString(GL_VERSION) << std::endl;
......
Markdown is supported
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