diff --git a/src/bsdfs/phong.cpp b/src/bsdfs/phong.cpp index 88d1a712..8bd7c82b 100644 --- a/src/bsdfs/phong.cpp +++ b/src/bsdfs/phong.cpp @@ -31,8 +31,11 @@ public: if (m_kd * m_diffuseColor->getMaximum().max() + m_ks * m_specularColor->getMaximum().max() > 1.0f) { Log(EWarn, "%s: Energy conservation is violated!", props.getID().c_str()); - Log(EWarn, "%s: Max. diffuse reflectance = %f * %f", m_kd, m_diffuseColor->getMaximum().max()); - Log(EWarn, "%s: Max. specular reflectance = %f * %f", m_ks, m_specularColor->getMaximum().max()); + Log(EWarn, "Max. diffuse reflectance = %f * %f", m_kd, m_diffuseColor->getMaximum().max()); + Log(EWarn, "Max. specular reflectance = %f * %f", m_ks, m_specularColor->getMaximum().max()); + Float normalization = 1/(m_kd * m_diffuseColor->getMaximum().max() + m_ks * m_specularColor->getMaximum().max()); + Log(EWarn, "Reducing the albedo to %.1f%% of the original value", normalization * 100); + m_kd *= normalization; m_ks *= normalization; } m_componentCount = 2; diff --git a/src/qtgui/importdlg.cpp b/src/qtgui/importdlg.cpp index a62446e8..6e86c7fb 100644 --- a/src/qtgui/importdlg.cpp +++ b/src/qtgui/importdlg.cpp @@ -108,7 +108,7 @@ void ImportDialog::accept() { QString targetScene = ui->sceneEdit->text(); QString adjustmentFile = ui->adjustmentEdit->text(); - QDialog *dialog = new QDialog(this); + QDialog *dialog = new QDialog(static_cast(parent())); dialog->setWindowModality(Qt::WindowModal); dialog->setWindowTitle("Converting .."); QVBoxLayout *layout = new QVBoxLayout(dialog); @@ -130,9 +130,9 @@ void ImportDialog::accept() { try { cvt.convert(sourceFile.toStdString(), directory.toStdString(), targetScene.toStdString(), adjustmentFile.toStdString()); - ((MainWindow *) parent())->loadFile(QString(cvt.getFilename().c_str())); dialog->hide(); delete dialog; + ((MainWindow *) parent())->loadFile(QString(cvt.getFilename().c_str())); } catch (const std::exception &ex) { dialog->hide(); delete dialog;