Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add depth-of-field (Blurring rendering options) #492

Merged
merged 9 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ void MainWindow::setupInterface()
if (pipeline) {
pipeline->setAoEnabled(
settings.value("MainWindow/ao_enabled", true).toBool());
pipeline->setDofEnabled(
settings.value("MainWindow/dof_enabled", true).toBool());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider disabling DoF by default to optimize performance for lower-end systems. Users can enable it as needed via settings. Thoughts? @ghutchis

Copy link
Contributor Author

@perminder-17 perminder-17 Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is still a work in progress PR and i want the shader file to be the best as needed and required. If you have any suggestions in this file for now https://github.com/OpenChemistry/avogadrolibs/pull/1662/files#diff-4f4a09755e6a3ad5776a815bd446b9ee8850fa794fea3aa67c1b1e2bd59e808e then please let me know.

I plan to incorporate various user settings for enabling and disabling depth of field (DOF) once the .glsl file functions as intended. While it's currently functional, I aim to align with @ghutchis plans for this feature.

pipeline->setFogEnabled(
settings.value("MainWindow/fog_enabled", true).toBool());
pipeline->setAoStrength(
Expand Down Expand Up @@ -1843,8 +1845,9 @@ void MainWindow::setRenderingSettings()
dialog.exec();
QSettings settings;
settings.setValue("MainWindow/ao_enabled", pipeline->getAoEnabled());
settings.setValue("MainWindow/fog_enabled", pipeline->getFogEnabled());
settings.setValue("MainWindow/ao_strength", pipeline->getAoStrength());
settings.setValue("MainWindow/dof_enabled", pipeline->getDofEnabled());
settings.setValue("MainWindow/fog_enabled", pipeline->getFogEnabled());
settings.setValue("MainWindow/ed_enabled", pipeline->getEdEnabled());
}
}
Expand Down
46 changes: 44 additions & 2 deletions avogadro/renderingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,27 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline)
: QDialog(parent_), m_ui(new Ui::RenderingDialog), m_solidPipeline(pipeline)
{
m_ui->setupUi(this);

m_ui->aoEnableCheckBox->setCheckState(pipeline.getAoEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->dofEnableCheckBox->setCheckState(pipeline.getDofEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->fogEnableCheckBox->setCheckState(pipeline.getFogEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->aoStrengthDoubleSpinBox->setMinimum(0.0);
m_ui->aoStrengthDoubleSpinBox->setValue(pipeline.getAoStrength());
m_ui->aoStrengthDoubleSpinBox->setMaximum(2.0);
m_ui->aoStrengthDoubleSpinBox->setDecimals(1);
m_ui->aoStrengthDoubleSpinBox->setSingleStep(0.1);
m_ui->dofStrengthDoubleSpinBox->setMinimum(0.0);
m_ui->dofStrengthDoubleSpinBox->setValue(pipeline.getDofStrength());
m_ui->dofStrengthDoubleSpinBox->setMaximum(2.0);
m_ui->dofStrengthDoubleSpinBox->setDecimals(1);
m_ui->dofStrengthDoubleSpinBox->setSingleStep(0.1);
m_ui->dofPositionDoubleSpinBox->setMinimum(0.0);
m_ui->dofPositionDoubleSpinBox->setValue(pipeline.getDofPosition());
// We can adjust the max and min value
// after testing with several molecules
m_ui->dofPositionDoubleSpinBox->setMaximum(20.0);
m_ui->dofPositionDoubleSpinBox->setDecimals(1);
m_ui->dofPositionDoubleSpinBox->setSingleStep(0.1);
m_ui->fogStrengthDoubleSpinBox->setMinimum(-20.0);
m_ui->fogStrengthDoubleSpinBox->setValue(pipeline.getFogStrength());
m_ui->fogStrengthDoubleSpinBox->setMaximum(20.0);
Expand All @@ -34,6 +47,8 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline)

connect(m_ui->aoEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(aoEnableCheckBoxChanged(int)));
connect(m_ui->dofEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(dofEnableCheckBoxChanged(int)));
connect(m_ui->fogEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(fogEnableCheckBoxChanged(int)));
connect(m_ui->saveButton, SIGNAL(clicked()),
Expand All @@ -52,6 +67,10 @@ bool RenderingDialog::aoEnabled()
return m_ui->aoEnableCheckBox->checkState() == Qt::Checked;
}

bool RenderingDialog::dofEnabled()
{
return m_ui->dofEnableCheckBox->checkState() == Qt::Checked;
}
bool RenderingDialog::fogEnabled()
{
return m_ui->fogEnableCheckBox->checkState() == Qt::Checked;
Expand All @@ -62,6 +81,15 @@ float RenderingDialog::aoStrength()
return m_ui->aoStrengthDoubleSpinBox->value();
}

float RenderingDialog::dofStrength()
{
return m_ui->dofStrengthDoubleSpinBox->value();
}

float RenderingDialog::dofPosition()
{
return m_ui->dofPositionDoubleSpinBox->value();
}
float RenderingDialog::fogStrength()
{
return m_ui->fogStrengthDoubleSpinBox->value();
Expand All @@ -77,7 +105,18 @@ bool RenderingDialog::edEnabled()
return m_ui->edEnableCheckBox->checkState() == Qt::Checked;
}

// TODO: will correct it.

void RenderingDialog::dofEnableCheckBoxChanged(int state)
{
if (state == Qt::Unchecked){
m_ui->dofStrengthDoubleSpinBox->setEnabled(false);
m_ui->dofPositionDoubleSpinBox->setEnabled(false);
}
else{
m_ui->dofStrengthDoubleSpinBox->setEnabled(true);
m_ui->dofPositionDoubleSpinBox->setEnabled(true);
}
}

void RenderingDialog::fogEnableCheckBoxChanged(int state)
{
Expand All @@ -102,7 +141,10 @@ void RenderingDialog::aoEnableCheckBoxChanged(int state)
void RenderingDialog::saveButtonClicked()
{
m_solidPipeline.setAoEnabled(aoEnabled());
m_solidPipeline.setDofEnabled(dofEnabled());
m_solidPipeline.setAoStrength(aoStrength());
m_solidPipeline.setDofStrength(dofStrength());
m_solidPipeline.setDofPosition(dofPosition());
m_solidPipeline.setFogStrength(fogStrength());
m_solidPipeline.setFogEnabled(fogEnabled());
m_solidPipeline.setFogPosition(fogPosition());
Expand Down
4 changes: 4 additions & 0 deletions avogadro/renderingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ class RenderingDialog : public QDialog
float aoStrength();
float fogStrength();
bool fogEnabled();
bool dofEnabled();
float dofStrength();
float dofPosition();
bool edEnabled();

protected slots:
void aoEnableCheckBoxChanged(int state);
void fogEnableCheckBoxChanged(int state);
void dofEnableCheckBoxChanged(int state);
void saveButtonClicked();
void closeButtonClicked();

Expand Down
Loading
Loading