Commit ae654756 authored by MURRAY David's avatar MURRAY David

variance fixed, save per-pixel variance over sample number (average on 7x7) mask

Still need to log per time
parent 09b17c17
Pipeline #106145 skipped with stage
......@@ -11,16 +11,65 @@ uniform vec2 viewport;
uniform int visu_mode;
uniform int alpha_layer;
uniform int display_picked;
uniform ivec2 picked_pos;
uniform int frame;
uniform int log_variance;
#define RADIANCE 0
#define ALPHA 1
#define VARIANCE 2
layout(std430, binding=0) buffer variance_picked
{
float data[];
};
layout(location = 0) out vec4 out_color;
float toRadiance(vec3 rgb)
{
return 0.2973769*rgb.r + 0.6273491 * rgb.g + 0.0752741 * rgb.b;
return 0.2973769 * rgb.r + 0.6273491 * rgb.g + 0.0752741 * rgb.b;
}
float getRadiance(ivec2 centralPos)
{
float sum = 0.0;//texelFetch(variance_buffer, centralPos, 0).r;
ivec2 pos = centralPos;
float weight[] = {
0.00000067, 0.00002292, 0.00019117, 0.00038771, 0.00019117, 0.00002292, 0.00000067,
0.00002292, 0.00078633, 0.00655965, 0.01330373, 0.00655965, 0.00078633, 0.00002292,
0.00019117, 0.00655965, 0.05472157, 0.11098164, 0.05472157, 0.00655965, 0.00019117,
0.00038771, 0.01330373, 0.11098164, 0.22508352, 0.11098164, 0.01330373, 0.00038771,
0.00019117, 0.00655965, 0.05472157, 0.11098164, 0.05472157, 0.00655965, 0.00019117,
0.00002292, 0.00078633, 0.00655965, 0.01330373, 0.00655965, 0.00078633, 0.00002292,
0.00000067, 0.00002292, 0.00019117, 0.00038771, 0.00019117, 0.00002292, 0.00000067
};
int x[] = {
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3,
-3, -2, -1, 0, 1, 2, 3
};
int y[] = {
-3, -3, -3, -3, -3, -3, -3,
-2, -2, -2, -2, -2, -2, -2,
-1, -1, -1, -1, -1, -1, -1,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3
};
for(int i = 0; i < 27; ++i)
sum += weight[i] * toRadiance(texelFetch(variance_buffer, centralPos + ivec2(x[i], y[i]), 0).rgb);
return sum;
}
void
......@@ -52,9 +101,25 @@ main(void)
}
else if(visu_mode == VARIANCE)
{
ret_color = texture(variance_buffer, screen_coord);
ret_color.rgb *= 100.0;
vec3 radMeanSqr = ret_color.rgb * ret_color.rgb;
vec3 radSqrMean = texture(variance_buffer, screen_coord).rgb;
ret_color.rgb = radSqrMean - radMeanSqr;
// ret_color = texture(variance_buffer, screen_coord);
// ret_color.rgb *= 100.0;
}
if(display_picked == 1)
{
vec2 screen_pick = picked_pos / viewport;
bool is_same_x = abs(screen_pick.x - screen_coord.x) <= 1.0/viewport.x;
bool is_same_y = abs(screen_pick.y - screen_coord.y) <= 1.0/viewport.y;
if(is_same_x || is_same_y)
ret_color.rgb = mix(ret_color.rgb, vec3(1.0, 1.0, 0.0), 0.2);
if(log_variance == 1)
if(is_same_x && is_same_y)
data[frame] = getRadiance(picked_pos);
}
out_color = ret_color;
}
......@@ -14,8 +14,8 @@ using mrf::uint;
#include "externals/imgui/imgui_impl_glfw.h"
#include "externals/imgui/imgui_impl_opengl3.h"
ImGUI::ImGUI(mrf::gui::fb::Loger::LEVEL const & logging_level):
GUI( logging_level ),
ImGUI::ImGUI(mrf::gui::fb::Loger::LEVEL const & logging_level) :
GUI(logging_level),
_ui_height(512), _ui_width(896),
_ui_panel_height(512),
_ui_panel_width(384)
......@@ -36,13 +36,13 @@ void ImGUI::initializeUI(mrf::rendering::OptixRenderer* renderer)
else
_renderer = renderer;
_width = (_renderer->hasScene())? _renderer->renderWidth() : 0;
_width = (_renderer->hasScene()) ? _renderer->renderWidth() : 0;
_ui_width = _width + _ui_panel_width;
_height = (_renderer->hasScene()) ? _renderer->renderHeight() : 512;
_ui_height = _height;
_ui_panel_height = _height;
_ui_height = _height;
createContext(_ui_width, _ui_height);
createContext(_ui_width, _ui_height);
_textureList[TextureName::COLOR] = Texture(_renderer->getDisplayBuffer(), "display_buffer");
_textureList[TextureName::OUTPUT] = Texture(_renderer->getOutputBuffer(), "display_buffer");
......@@ -150,8 +150,8 @@ void ImGUI::controlPanel(UI_MODE mode)
{
makeHeadStraight();
}
ImGui::SameLine();
ImGui::Text("(aligned with(0, 1, 0))");
ImGui::SameLine();
ImGui::Text("(aligned with(0, 1, 0))");
if (ImGui::Button("Next Camera"))
{
nextCamera();
......@@ -161,14 +161,14 @@ void ImGUI::controlPanel(UI_MODE mode)
{
previousCamera();
}
if (ImGui::Button("Reset Camera"))
{
resetCamera();
}
ImGui::SameLine();
if (ImGui::Button("Reset Camera"))
{
resetCamera();
}
ImGui::SameLine();
if (ImGui::Button("Save Camera"))
{
_render_on_pause = true;
_render_on_pause = true;
ImGui::OpenPopup("Camera file name");
}
saveCamera();
......@@ -233,14 +233,14 @@ void ImGUI::controlPanel(UI_MODE mode)
if (ImGui::Button("Save image"))
{
_render_on_pause = true;
ImGui::OpenPopup("Image file name");
ImGui::OpenPopup("Image file name");
}
saveImage();
if (ImGui::Button("Load scene"))
{
_render_on_pause = true;
ImGui::OpenPopup("Scene file name");
ImGui::OpenPopup("Scene file name");
}
openScene();
}
......@@ -258,7 +258,7 @@ void ImGUI::controlPanel(UI_MODE mode)
#ifdef MRF_RENDERING_MODE_SPECTRAL
uint wpp = _renderer->getSpectralWavelengths().size() / _renderer->getWavelengthsPerPass().size();
if(wpp > 1)
if (wpp > 1)
ImGui::Text("Rendering %u wavelengths per pass.", wpp);
else
ImGui::Text("Rendering %u wavelength per pass.", wpp);
......@@ -305,13 +305,13 @@ void ImGUI::display()
if (_renderer->hasScene())
{
glViewport(0, 0, _width, _height);
if (_display_output_buffer_directly)
mrf::optix_backend::displayBufferGL(_renderer->getOutputBuffer(), mrf::optix_backend::BUFFER_PIXEL_FORMAT_DEFAULT, true);
else
mrf::optix_backend::displayBufferGL(_renderer->getDisplayBuffer(), mrf::optix_backend::BUFFER_PIXEL_FORMAT_DEFAULT, true);
glViewport(0, 0, _ui_width, _ui_height);
}
}
if (_redraw_ui)
{
......@@ -319,7 +319,7 @@ void ImGUI::display()
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
if(_current_mode == UI_MODE::INIT)
if (_current_mode == UI_MODE::INIT)
_current_mode = UI_MODE::DISPLAY;
}
......@@ -335,7 +335,7 @@ void ImGUI::mouseMotion(double x, double y)
{
ImGuiIO& io = ImGui::GetIO();
if(!io.WantCaptureMouse) // Avoid passing moving events to the application when an ImGui widget is active
if (!io.WantCaptureMouse) // Avoid passing moving events to the application when an ImGui widget is active
GUI::mouseMotion((double)x, (double)y);
}
......@@ -351,7 +351,7 @@ void ImGUI::keyboardPress(int key, int scancode, int action, int mods)
{
ImGuiIO& io = ImGui::GetIO();
if(!io.WantTextInput) // Avoid passing keyboard events to the application when a text input is expected by ImGui.
if (!io.WantTextInput) // Avoid passing keyboard events to the application when a text input is expected by ImGui.
GUI::keyboardPress(key, scancode, action, mods);
}
......@@ -391,7 +391,7 @@ void ImGUI::dropEvent(GLFWwindow* window, int count, const char** paths)
if (checkScene(scene))
{
resizeAppWindow(_renderer->renderWidth() + _ui_panel_width, _renderer->renderHeight());
resizeAppWindow(_renderer->renderWidth() + _ui_panel_width, _renderer->renderHeight());
}
}
......@@ -405,7 +405,7 @@ void ImGUI::openScene()
if (ImGui::BeginPopupModal("Scene file name", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove))
{
ImGui::Text("Input name:");
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.45f*0.8, 0.55f*0.8, 0.60f*0.8, 1));
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.45f*0.8, 0.55f*0.8, 0.60f*0.8, 1));
input_text_scene.assign(_scene_file.begin(), _scene_file.end());
input_text_scene.resize(256);
ImGui::InputText("##edit", (char*)input_text_scene.c_str(), input_text_scene.capacity() + 1);
......
......@@ -18,10 +18,22 @@ using optix::float3;
ImGUI_shader::ImGUI_shader(mrf::gui::fb::Loger::LEVEL const & logging_level) :
ImGUI(logging_level), _fbo_ready(false), _quad_ready(false), _ssbo_ready(false)
{
_requestedMode = VisuMode::RADIANCE;
_requestedMode = VisuMode::RADIANCE;
_alpha_layer = 0;
_use_sample_balancing = true;
_reset_on_iteration = true;
_is_picking = false;
_picking_pos[0] = 0;
_picking_pos[1] = 0;
_display_picked = false;
_ssbo = 0;
_log_variance = false;
_log_time = false;
_variance_samples = 128;
_variance = nullptr;
_time = nullptr;
}
ImGUI_shader::~ImGUI_shader()
......@@ -54,6 +66,15 @@ void ImGUI_shader::customUI(ImGUI::UI_MODE mode)
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
ImGui::Combo("Visualization", &_requestedMode, items, IM_ARRAYSIZE(items));
ImGui::SameLine();
if (ImGui::Button("Save buffer"))
{
if (_requestedMode == VisuMode::RADIANCE)
_renderer->saveImage(_image_output_file.substr(0, _image_output_file.find(".exr")) + "_radiance.exr", "display_buffer");
else
_renderer->saveImage(_image_output_file.substr(0, _image_output_file.find(".exr")) + "_alpha.png", "alpha_buffer");
}
if (ImGui::Checkbox("Sample balancing", &_use_sample_balancing))
{
_renderer->setBalancing(_use_sample_balancing);
......@@ -65,14 +86,6 @@ void ImGUI_shader::customUI(ImGUI::UI_MODE mode)
_camera_changed = true;
}
if (ImGui::Button("Save buffer"))
{
if (_requestedMode == VisuMode::RADIANCE)
_renderer->saveImage(_image_output_file.substr(0, _image_output_file.find(".exr")) + "_radiance.exr", "display_buffer");
else
_renderer->saveImage(_image_output_file.substr(0, _image_output_file.find(".exr")) + "_alpha.png", "alpha_buffer");
}
int samples_alpha = _renderer->getSamplesAlpha();
int sample_step = 128;
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
......@@ -91,15 +104,39 @@ void ImGUI_shader::customUI(ImGUI::UI_MODE mode)
_camera_changed = true;
}
if(_renderer->getMaxPathLength() > 1)
ImGui::SliderInt("Alpha layer", &_alpha_layer, 0, _renderer->getMaxPathLength()-1);
if (_renderer->getMaxPathLength() > 1)
ImGui::SliderInt("Alpha layer", &_alpha_layer, 0, _renderer->getMaxPathLength() - 1);
float alpha = _renderer->getStartAlpha();
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
if (ImGui::SliderFloat("Alpha start value", &alpha, 0.f, 1.f))
{
_renderer->setStartAlpha(alpha);
_camera_changed = true;
}
ImGui::Checkbox("Picking", &_is_picking);
ImGui::SameLine();
ImGui::Checkbox("Display picked", &_display_picked);
int step = 1;
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
ImGui::InputScalar("X", ImGuiDataType_U32, &_picking_pos[0], &step, NULL);
ImGui::SameLine();
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
ImGui::InputScalar("Y", ImGuiDataType_U32, &_picking_pos[1], &step, NULL);
if (ImGui::Button("Save variance at picked point") && !_log_variance)
{
_render_on_pause = true;
ImGui::OpenPopup("Variance");
}
variancePopUp();
if (_log_variance)
if (ImGui::Button("Cancel variance log"))
stopVarianceLog();
}
}
......@@ -134,19 +171,24 @@ void ImGUI_shader::display()
glViewport(0, 0, _width, _height);
//initFrameBuffer();
initQuad();
if (!_ssbo_ready)
initSSBO();
render(&_shaderProg, true);
glViewport(0, 0, _ui_width, _ui_height);
//Our rendering have been done, now ImGui will execute its drawing command (must be done in this order to ensure correct behavior of popups).
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
GLenum error = glGetError();
if (error != GL_NONE)
if (_log_variance && _frame == _variance_samples-1)
{
std::cerr << "GL Error " << error << " in function Display." << std::endl;
saveVarianceAtPicked();
_log_variance = false;
_log_time = false;
}
_current_mode = UI_MODE::DISPLAY;
_frame++;
}
void ImGUI_shader::render(Shader* prg, bool use_tex)
......@@ -161,10 +203,13 @@ void ImGUI_shader::render(Shader* prg, bool use_tex)
_textureList[TextureName::VARIANCE].activate(prg);
}
bindSSBO();
setParameters(prg);
displayQuad(prg);
unbindSSBO();
if (use_tex)
{
_textureList[TextureName::COLOR].deactivate();
......@@ -253,6 +298,10 @@ void ImGUI_shader::setParameters(Shader* prg)
glUniform2f(prg->getUniformLocation("viewport"), static_cast<float>(_width), static_cast<float>(_height));
glUniform1i(prg->getUniformLocation("visu_mode"), _requestedMode);
glUniform1i(prg->getUniformLocation("alpha_layer"), _alpha_layer);
glUniform1i(prg->getUniformLocation("display_picked"), _display_picked);
glUniform2i(prg->getUniformLocation("picked_pos"), _picking_pos[0], _picking_pos[1]);
glUniform1i(prg->getUniformLocation("frame"), _frame);
glUniform1i(prg->getUniformLocation("log_variance"), _log_variance);
}
void ImGUI_shader::mousePress(int button, int action, int mods)
......@@ -261,7 +310,14 @@ void ImGUI_shader::mousePress(int button, int action, int mods)
if (!io.WantCaptureMouse) // Avoid passing event to the application when a GUI widget is active
{
GUI::mousePress(button, action, mods);
if (!_is_picking)
GUI::mousePress(button, action, mods);
else if (io.MouseDown[0])
{
_picking_pos[0] = io.MouseClickedPos->x;
_picking_pos[1] = _width - io.MouseClickedPos->y;
_is_picking = false;
}
}
}
......@@ -278,5 +334,167 @@ void ImGUI_shader::charPress(unsigned int codepoint)
_shaderProg.loadFromFiles(pathToShaders + "simple.vert", pathToShaders + "simple.frag");
}
if (codepoint == 'm')
{
_is_picking = 1 - _is_picking;
}
}
}
void ImGUI_shader::activateVarianceLog()
{
delete _variance;
delete _time;
_log_variance = true;
_variance = new float[_variance_samples];
for (int i = 0; i < _variance_samples; ++i)
_variance[i] = 0.f;
if (_log_time)
_time = new float[_variance_samples];
else
_time = nullptr;
updateSSBO();
}
void ImGUI_shader::stopVarianceLog()
{
delete _variance;
delete _time;
_log_variance = false;
_log_time = false;
initSSBO();
}
void ImGUI_shader::addVarianceItem(int iteration, float log_time)
{
if (_variance != nullptr)
{
}
if (_time != nullptr && log_time > 0.f)
_time[iteration] = log_time;
}
void ImGUI_shader::initSSBO()
{
if (_ssbo == 0)
glGenBuffers(1, &_ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float), nullptr, GL_DYNAMIC_COPY);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
_ssbo_ready = true;
}
void ImGUI_shader::updateSSBO()
{
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float)*_variance_samples, (GLfloat*)_variance, GL_DYNAMIC_COPY);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
_ssbo_ready = true;
}
void ImGUI_shader::bindSSBO()
{
if (_ssbo_ready)
{
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, _ssbo);
}
}
void ImGUI_shader::unbindSSBO()
{
if (_ssbo_ready)
{
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
}
}
void ImGUI_shader::saveVarianceAtPicked()
{
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
bindSSBO();
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _ssbo);
float* variance_ptr = (float*)glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_WRITE);
if (variance_ptr != nullptr)
memcpy(_variance, variance_ptr, _variance_samples * sizeof(float));
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
unbindSSBO();
std::ofstream file;
std::string filename;
filename = _image_output_file.substr(0, _image_output_file.size() - 4) + "variance.txt";
file.open(filename, std::ios::out);
for (int i = 0; i < _variance_samples; ++i)
{
file << std::to_string(i) << " " << std::to_string(_variance[i]);
if (_log_time)
file << " " << std::to_string(_time[i]);
file << "\n";
}
//file << std::endl;
file.close();
_loger.info("Saved variance at picked position for " + std::to_string(_variance_samples) + " samples");
_loger.info("Output file at: " + filename);
delete _variance;
_variance = nullptr;
delete _time;
_time = nullptr;
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float), nullptr, GL_DYNAMIC_COPY);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
}
void ImGUI_shader::variancePopUp()
{
if (ImGui::BeginPopupModal("Variance", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove))
{
bool should_close = false;
bool launch = false;
bool cancel = false;
int sample_step = 128, tmp = _variance_samples;
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.45f*0.8, 0.55f*0.8, 0.60f*0.8, 1));
ImGui::SetNextItemWidth(_ui_panel_width / 4.f);
ImGui::InputScalar("Number of samples used for variance", ImGuiDataType_U32, &_variance_samples, &sample_step, NULL);
ImGui::Checkbox("Log time", &_log_time);
cancel = ImGui::Button("Cancel");
ImGui::SameLine();
launch = ImGui::Button("Launch variance computation");
should_close = launch | cancel;
if (should_close)
{
if (launch)
{
activateVarianceLog();
_render_on_pause = false;
_camera_changed = true;
}
else if (cancel)
_variance_samples = tmp;
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
else
{
ImGui::EndPopup();
}
}
}
......@@ -50,6 +50,18 @@ private:
void initQuad();
void displayQuad(Shader* prg);
void activateVarianceLog();
void stopVarianceLog();
void saveVarianceAtPicked();
void addVarianceItem(int iteration, float log_time = 0.f);
void initSSBO();
void updateSSBO();
void bindSSBO();
void unbindSSBO();
void variancePopUp();
enum VisuMode {
RADIANCE,
ALPHA,
......@@ -64,4 +76,13 @@ private:
int _requestedMode;
bool _is_picking;
bool _display_picked;
int _picking_pos[2];
bool _log_variance;
bool _log_time;
int _variance_samples;
float* _variance;
float* _time;
};
......@@ -172,7 +172,7 @@ bool GUI::doRendering()
//RGB MODE: just need to launch context and increment num frame
//No need to updateMaterials or light, already done once at init
#ifndef MRF_RENDERING_MODE_SPECTRAL
if (_renderer->getNumFrame() < 10000)
//if (_renderer->getNumFrame() < 10000)
{
_renderer->_context->launch(0, _width, _height);
_renderer->incrementNumFrame();
......@@ -555,8 +555,9 @@ void GUI::updateCamera()
_renderer->resetNumFrame();
#endif
_renderer->setNumPass(0);
_renderer->setNumPass(0);
_frame = 0;
}
_camera_changed = false;
}
......
......@@ -102,6 +102,8 @@ protected:
std::vector<Texture> _textureList;
unsigned int _displayTexture;
int _frame;
enum TextureName {
COLOR,
OUTPUT,
......
......@@ -238,7 +238,8 @@ RT_PROGRAM void pathtrace_camera()
seed = prd.seed;
Metrics all_metrics = metrics_buffer[make_uint3(launch_index, 0)];
if(all_metrics.nb_samples < alpha_samples * alpha_passes)
// if(all_metrics.nb_samples < alpha_samples * alpha_passes)
if(frame_number < alpha_samples * alpha_passes)
{
int path_depth = 0;
if(!all_metrics.is_bg)
......@@ -256,7 +257,7 @@ RT_PROGRAM void pathtrace_camera()
metrics_buffer[make_uint3(launch_index, path_depth)].alpha_comp += make_float2(toRad1, toRad2);
if((nb_samples+1)%alpha_samples == 0)
if((frame_number)%alpha_samples == 0)
{
float2 alpha_comp = metrics_buffer[make_uint3(launch_index, path_depth)].alpha_comp/(float)(alpha_samples);
......@@ -344,24 +345,21 @@ RT_PROGRAM void pathtrace_camera()
output_buffer[launch_index] = pixel_color;
#endif
#else
float3 variance = pixel_color * pixel_color;
float3 xiSqr = pixel_color * pixel_color;
float3 xiSqrSum = xiSqr; //init to xiSqr, updated to sum if needed;
if (frame_number > 1)
{
float a = 1.0f / (float)frame_number;
// if (metrics_buffer[launch_index].nb_samples%alpha_samples > 1)
// {
// float a = 1.0f / (float)(metrics_buffer[launch_index].nb_samples%alpha_samples);
float3 old_color = make_float3(output_buffer[launch_index]);
pixel_color = lerp( old_color, pixel_color, a ); //pixel_color is now equivalent to radiance_mean
float3 old_var = make_float3(variance_buffer[launch_index]);
variance = lerp( old_var, variance, a );
xiSqrSum = make_float3(variance_buffer[launch_index]);// get sum of sqr xi up to n-1 (=mean of sqr)
xiSqrSum = lerp( xiSqrSum, xiSqr, a); //lerp to add the nth to the mean of sqr
}
output_buffer[launch_index] = make_float4(pixel_color,1.f);
variance = variance - pixel_color*pixel_color; //pixel_color is equivalent to radiance_mean
variance_buffer[launch_index] = make_float4(variance.x, variance.y, variance.z, 1.f);
variance_buffer[launch_index] = make_float4(xiSqrSum.x, xiSqrSum.y, xiSqrSum.z, 1.f);
//interactive rgb mode
#ifdef INTERACTIVE_MODE
......
......@@ -443,8 +443,12 @@ void applyLoadXForm(mrf::optix_backend::Mesh& mesh, const float* load_xform)
bool have_matrix = false;
for (int32_t i = 0; i < 16; ++i)
{
if (load_xform[i] != 0.0f)
{
have_matrix = true;
}
}
if (have_matrix)
{
......
......@@ -196,8 +196,11 @@ def export_meshes(root_node, directory_full_path, directory_relative_path, use_p
if(glossy_distribution=="SHARP"):
sharp_bsdf = True
roughness_to_phong = 2.0 * pow(specular_node.inputs[1].default_value, -2) - 2.0
roughness = (roughness_to_phong,kd,ks)
if specular_node.inputs[1].default_value == 0:
roughness = 1.0
else:
roughness_to_phong = 2.0 * pow(specular_node.inputs[1].default_value, -2) - 2.0
roughness = (roughness_to_phong,kd,ks)
r_spec = specular_node.inputs[0].default_value[0]
g_spec = specular_node.inputs[0].default_value[1]
b_spec = specular_node.inputs[0].default_value[2]
......
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