Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
added:
-- presets filter
-- DOF post processing
  • Loading branch information
kmkolasinski committed Apr 18, 2015
1 parent 39ad688 commit 7731a13
Show file tree
Hide file tree
Showing 19 changed files with 629 additions and 71 deletions.
Binary file modified BuildingInstruction.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions Sources/CommonObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ class Performance3DSettings{
int noTessSubdivision;
int noPBRRays;
bool bBloomEffect;
bool bDofEffect;
Performance3DSettings(){
bUseCullFace = false;
bUseSimplePBR = false;
noTessSubdivision = 16;
noPBRRays = 15;
bBloomEffect = true;
bDofEffect = true;
}
};

Expand Down Expand Up @@ -437,6 +439,7 @@ class FBOImageProporties{
float heightMaxValue;
int heightAveragingRadius;
float heightOffsetValue;
bool bHeightEnableNormalization;


// selective blur variables
Expand Down Expand Up @@ -552,6 +555,7 @@ class FBOImageProporties{
heightMaxValue = 1.0;
heightAveragingRadius = 1;
heightOffsetValue = 0.0;
bHeightEnableNormalization = true;

// selective blur variables
selectiveBlurType = SELECTIVE_BLUR_DIFFERENCE_OF_GAUSSIANS;
Expand Down
3 changes: 3 additions & 0 deletions Sources/formimageprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ FormImageProp::FormImageProp(QMainWindow *parent, QGLWidget* qlW_ptr) :
connect(ui->horizontalSliderHeightProcMaxValue,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderHeightAveRadius ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderHeightOffsetValue ,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->checkBoxHeightProcEnableNormalization ,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));

connect(ui->horizontalSliderHeightProcMinValue,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
connect(ui->horizontalSliderHeightProcMaxValue,SIGNAL(sliderMoved(int)),this,SLOT(updateGuiSpinBoxesAndLabes(int)));
Expand Down Expand Up @@ -517,6 +518,7 @@ void FormImageProp::updateGuiCheckBoxes(){
imageProp.bRoughnessEnableColorPicking = ui->radioButtonEnableColorPicking->isChecked();
imageProp.bRoughnessInvertColorMask = ui->checkBoxRoughnessColorInvert->isChecked();

imageProp.bHeightEnableNormalization = ui->checkBoxHeightProcEnableNormalization->isChecked();

if(imageProp.bRoughnessEnableColorPicking){
if(!imageProp.bRoughnessColorPickingToggled)ui->groupBoxGeneral->setDisabled(true);
Expand Down Expand Up @@ -698,6 +700,7 @@ void FormImageProp::reloadSettings(){
ui->horizontalSliderHeightProcMaxValue ->setValue(imageProp.heightMaxValue*200);
ui->horizontalSliderHeightProcMinValue ->setValue(imageProp.heightMinValue*200);
ui->horizontalSliderHeightOffsetValue ->setValue(imageProp.heightOffsetValue*100);
ui->checkBoxHeightProcEnableNormalization->setChecked(imageProp.bHeightEnableNormalization);

ui->labelHeightProcMinValue ->setText(QString::number(imageProp.heightMinValue));
ui->labelHeightProcMaxValue ->setText(QString::number(imageProp.heightMaxValue));
Expand Down
10 changes: 10 additions & 0 deletions Sources/formimageprop.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,16 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QCheckBox" name="checkBoxHeightProcEnableNormalization">
<property name="text">
<string>Enable normalization</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
Expand Down
15 changes: 14 additions & 1 deletion Sources/formsettingscontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FormSettingsContainer::FormSettingsContainer(QWidget *parent) :
connect(ui->pushButtonConfirm,SIGNAL(released()),this,SLOT(addNewSettingsField()));
connect(ui->pushButtonConfirm,SIGNAL(released()),this,SLOT(toggleAdding()));
connect(ui->pushButtonCancel ,SIGNAL(released()),this,SLOT(toggleAdding()));
connect(ui->lineEditFilterPreset,SIGNAL(textEdited(QString)),this,SLOT(filterPresets(QString)));
ui->groupBoxAddingOptions->hide();
ui->verticalLayoutSettingsList->setAlignment(Qt::AlignTop);

Expand All @@ -20,7 +21,7 @@ FormSettingsContainer::FormSettingsContainer(QWidget *parent) :
QStringList nameFilter("*.ini");
QDir directory("Configs/");
QStringList iniFiles = directory.entryList(nameFilter);
qDebug() << "Reading the list of available configs settings:" << iniFiles;
qDebug() << "Reading the list of available configs settings:";
// reading configs
for (int i = 0; i < iniFiles.size(); ++i){
FormSettingsField* sfield = new FormSettingsField("Configs/"+iniFiles[i],this);
Expand Down Expand Up @@ -81,3 +82,15 @@ void FormSettingsContainer::saveSettings(){
}
emit forceSaveCurrentConfig();
}

void FormSettingsContainer::filterPresets(QString filter){

// check if string filter is present in presets names
for(int i = 0 ; i < settingsList.size() ; i++){
if(settingsList[i]->getName().contains(QRegExp(".*"+filter+".*",Qt::CaseInsensitive))){
settingsList[i]->show();
}else{
settingsList[i]->hide();
}
}// end of for
}
3 changes: 2 additions & 1 deletion Sources/formsettingscontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public slots:
void removeSetting(FormSettingsField* field); // destroys also files
void reloadSettings(FormSettingsField* field);
void saveSettings();

void filterPresets(QString filter);
signals:
void reloadConfigFile(); // force main window to read config.ini again
void forceSaveCurrentConfig(); // current configs will be save to config.ini file
private:

Ui::FormSettingsContainer *ui;
QVector<FormSettingsField*> settingsList;
};
Expand Down
60 changes: 51 additions & 9 deletions Sources/formsettingscontainer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,56 @@
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="pushButtonAddNew">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonAddNew">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add preset</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Filter</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="lineEditFilterPreset">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxAddingOptions">
Expand Down Expand Up @@ -176,7 +218,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>457</width>
<height>98</height>
<height>96</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down
3 changes: 3 additions & 0 deletions Sources/formsettingsfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ FormSettingsField::~FormSettingsField()
delete ui;
}

const QString& FormSettingsField::getName(){
return name;
}

void FormSettingsField::deleteSettings(){
QFile::remove(settingsPath);
Expand Down
3 changes: 2 additions & 1 deletion Sources/formsettingsfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FormSettingsField : public QWidget
FormSettingsField(QString _name,QString _description, QWidget *parent = 0);
// Load Settings From File
FormSettingsField(QString _config_name, QWidget *parent = 0);

const QString& getName();
~FormSettingsField();
public slots:
void deleteSettings();// remove files
Expand All @@ -29,6 +29,7 @@ public slots:
void nameChanged(QString text);
void resetBackGroundColor();


signals:
void emitDeleteSettings(FormSettingsField*);
void emitSaveSettings();
Expand Down
48 changes: 42 additions & 6 deletions Sources/glimageeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,9 @@ void GLImage::applyMixNormalLevels(GLuint level0,
void GLImage::applyCPUNormalizationFilter(QGLFramebufferObject* inputFBO,
QGLFramebufferObject* outputFBO){




GLCHK( glActiveTexture(GL_TEXTURE0) );
GLCHK( glBindTexture(GL_TEXTURE_2D, inputFBO->texture()) );
GLint textureWidth, textureHeight;
Expand All @@ -2029,14 +2032,46 @@ void GLImage::applyCPUNormalizationFilter(QGLFramebufferObject* inputFBO,
float min[3] = {img[0],img[1],img[2]};
float max[3] = {img[0],img[1],img[2]};

for(int i = 0 ; i < textureWidth*textureHeight ; i++){
//qDebug() << "i=" <<i << "\t" << img[3*i+0] << "\t" << img[3*i+1] << "\t" << img[3*i+2];
for(int c = 0 ; c < 3 ; c++){
if( max[c] < img[3*i+c] ) max[c] = img[3*i+c];
if( min[c] > img[3*i+c] ) min[c] = img[3*i+c];
// if materials are enabled one must calulate height only in the
// region of selected material color
if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
QImage maskImage = targetImageMaterial->getImage();
int currentMaterialIndex = FBOImageProporties::currentMaterialIndeks;
// number of components
int nc = maskImage. byteCount () / (textureWidth*textureHeight) ;
bool bFirstTimeChecked = true;
unsigned char * data = maskImage.bits();
for(int i = 0 ; i < textureWidth*textureHeight ; i++){
int materialColor = data[nc*i+0]*255*255 + data[nc*i+1]*255 + data[nc*i+2];
if(materialColor == currentMaterialIndex){
if(bFirstTimeChecked){
for(int c = 0 ; c < 3 ; c++){
min[c] = img[3*i+c];
max[c] = max[c];
}
bFirstTimeChecked = false;
}// end of if first time

for(int c = 0 ; c < 3 ; c++){
if( max[c] < img[3*i+c] ) max[c] = img[3*i+c];
if( min[c] > img[3*i+c] ) min[c] = img[3*i+c];
}
}// end of if material colors are same
}// end of loop over image

}else{// if materials are disabled calculate
for(int i = 0 ; i < textureWidth*textureHeight ; i++){
for(int c = 0 ; c < 3 ; c++){
if( max[c] < img[3*i+c] ) max[c] = img[3*i+c];
if( min[c] > img[3*i+c] ) min[c] = img[3*i+c];
}
}
}// end of if materials are enables

// prevent from singularities
for(int k = 0; k < 3 ; k ++)
if(qAbs(min[k] - max[k]) < 0.0001) max[k] += 0.1;

}

qDebug() << "Image normalization:";
qDebug() << "Min color = (" << min[0] << "," << min[1] << "," << min[2] << ")" ;
Expand Down Expand Up @@ -2137,6 +2172,7 @@ void GLImage::applyHeightProcessingFilter(QGLFramebufferObject* inputFBO,
GLCHK( program->setUniformValue("gui_height_proc_max_value" ,activeImage->heightMaxValue) );
GLCHK( program->setUniformValue("gui_height_proc_ave_radius" ,activeImage->heightAveragingRadius) );
GLCHK( program->setUniformValue("gui_height_proc_offset_value",activeImage->heightOffsetValue) );
GLCHK( program->setUniformValue("gui_height_proc_normalization",activeImage->bHeightEnableNormalization) );
}
GLCHK( glViewport(0,0,inputFBO->width(),inputFBO->height()) );
GLCHK( outputFBO->bind() );
Expand Down
Loading

0 comments on commit 7731a13

Please sign in to comment.