Skip to content

Commit

Permalink
grunge maps added
Browse files Browse the repository at this point in the history
some steps towards grunge textures are implemented
still not tested on linux
  • Loading branch information
kmkolasinski committed May 10, 2015
1 parent 428a839 commit beb00b7
Show file tree
Hide file tree
Showing 14 changed files with 1,231 additions and 268 deletions.
6 changes: 6 additions & 0 deletions Sources/CommonObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ bool FBOImageProporties::bSeamlessTranslationsFirst = true;
int FBOImageProporties::seamlessMirroModeType = 0;
bool FBOImageProporties::bConversionBaseMap = false;

float FBOImageProporties::grungeOverallWeight = 0.0; // general weight for all images
float FBOImageProporties::grungeRadius = 25.0; // general weight for all images
bool FBOImageProporties::bGrungeEnableRandomTranslations = false; //
bool FBOImageProporties::bGrungeReplotAllWhenChanged = true;
int FBOImageProporties::grungeSeed = 0; // grunge randomization seed (if = 0 no randomization)

map<QString,int> FBOImageProporties::materialIndices;
int FBOImageProporties::currentMaterialIndeks = MATERIALS_DISABLED;

Expand Down
29 changes: 26 additions & 3 deletions Sources/CommonObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "qopenglerrorcheck.h"
#include <QOpenGLFunctions_3_3_Core>

#define TAB_SETTINGS 8
#define TAB_TILING 9
#define TAB_SETTINGS 9
#define TAB_TILING 10

#ifdef Q_OS_MAC
# define AB_INI "AwesomeBump.ini"
Expand Down Expand Up @@ -46,6 +46,7 @@ enum TextureTypes{
ROUGHNESS_TEXTURE,
METALLIC_TEXTURE,
MATERIAL_TEXTURE,
GRUNGE_TEXTURE,
MAX_TEXTURES_TYPE
};

Expand Down Expand Up @@ -129,6 +130,8 @@ enum MaterialIndicesType{
MATERIALS_ENABLED = -1
};



#define TARGA_HEADER_SIZE 0x12
#define TARGA_UNCOMP_RGB_IMG 0x02
#define TARGA_UNCOMP_BW_IMG 0x03
Expand Down Expand Up @@ -221,6 +224,8 @@ class PostfixNames{
break;
case(MATERIAL_TEXTURE ):
return "material";
case(GRUNGE_TEXTURE ):
return "grunge";
break;
default: return "default-diffuse";
}
Expand Down Expand Up @@ -279,8 +284,11 @@ struct RandomTilingMode{
}
// generate random angles
void randomize(){
static int seed = 312;
qsrand(seed);
seed = qrand() % 41211; // fake seed
for(int i = 0; i < 9 ; i++){
angles[i] = 2 * 3.1415269 * rand() / (RAND_MAX + 0.0);
angles[i] = 2 * 3.1415269 * qrand() / (RAND_MAX + 0.0);
}
}
};
Expand Down Expand Up @@ -504,6 +512,15 @@ class FBOImageProporties{
float normalMixerPosX;
float normalMixerPosY;

// grunge settings
static float grungeOverallWeight; // general weight for all images
static int grungeSeed; // grunge randomization seed (if = 0 no randomization)
static float grungeRadius; // random radius
static bool bGrungeReplotAllWhenChanged;
float grungeImageWeight; // per image additional weight
float grungeMainImageWeight; // used for normal blending only
static bool bGrungeEnableRandomTranslations;
unsigned int grungeBlendingMode;
// global settings seamless parameters

static SeamlessMode seamlessMode;
Expand Down Expand Up @@ -635,6 +652,12 @@ class FBOImageProporties{
normalMixerPosX = 0.0;
normalMixerPosY = 0.0;

// grunge settings
grungeImageWeight = 0.0;
grungeBlendingMode = 0;
grungeMainImageWeight = 0.0;


}

void copySettings(FBOImageProporties &src){
Expand Down
5 changes: 3 additions & 2 deletions Sources/formimagebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ void FormImageBase::open()
QFileDialog dialog(this,
tr("Open File"),
picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.first(),
tr("All Images (*.png *.jpg *.tga *.jpeg *.bmp);;"
tr("All Images (*.png *.jpg *.tga *.jpeg *.bmp *.tif);;"
"Images (*.png);;"
"Images (*.jpg);;"
"Images (*.tga);;"
"Images (*.jpeg);;"
"Images (*.bmp);;"
"Images (*.tif);;"
"All files (*.*)"));
dialog.setAcceptMode(QFileDialog::AcceptOpen);

Expand Down Expand Up @@ -90,7 +91,7 @@ void FormImageBase::save(){
QFileDialog dialog(this,
tr("Save current image to file"),
picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.first(),
tr("All images (*.png *.jpg *.tga *.jpeg *.bmp);;All files (*.*)"));
tr("All images (*.png *.jpg *.tga *.jpeg *.bmp *.tif);;All files (*.*)"));
dialog.setDirectory(recentDir->absolutePath());
dialog.setAcceptMode(QFileDialog::AcceptSave);

Expand Down
86 changes: 83 additions & 3 deletions Sources/formimageprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ FormImageProp::FormImageProp(QMainWindow *parent, QGLWidget* qlW_ptr) :
connect(ui->horizontalSliderNormalMixerPosX,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderNormalMixerPosY,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));

// grunge
connect(ui->horizontalSliderGrungeOverallWeight,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderGrungeSeed,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderGrungeRadius,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->checkBoxGrungeRandomTranslations,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));
connect(ui->checkBoxGrungeReplotAllAfterChange,SIGNAL(clicked()),this,SLOT(updateGuiCheckBoxes()));

connect(ui->horizontalSliderGrungeImageWeight,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->horizontalSliderGrungeMainImageWeight,SIGNAL(sliderReleased()),this,SLOT(updateSlidersOnRelease()));
connect(ui->comboBoxGrungeBlendingMode,SIGNAL(activated(int)),this,SLOT(updateComboBoxes(int)));
// this actually invert all color components
connect(ui->checkBoxGrungeInvert,SIGNAL(toggled(bool)),this,SLOT(invertGrunge(bool)));


setAcceptDrops(true);
Expand Down Expand Up @@ -215,7 +227,12 @@ FormImageProp::FormImageProp(QMainWindow *parent, QGLWidget* qlW_ptr) :
// normal mixer
ui->groupBoxNormalMixerSettings->hide();
ui->groupBoxNormalMixer->hide();
ui->groupBoxGrungeSettings->hide();
ui->groupBoxGrungeImageSettings->hide();

ui->labelGrungeImageWeight->hide();
ui->labelGrungeImageWeight2->hide();
ui->horizontalSliderGrungeMainImageWeight->hide();
setMouseTracking(true);
setFocus();
setFocusPolicy(Qt::ClickFocus);
Expand Down Expand Up @@ -310,6 +327,7 @@ void FormImageProp::updateComboBoxes(int index){
// updating selective blur groupboxes
imageProp.selectiveBlurType = (SelectiveBlurType) ui->comboBoxSelectiveBlurTypes->currentIndex();


switch(imageProp.selectiveBlurType){
case(SELECTIVE_BLUR_DIFFERENCE_OF_GAUSSIANS):
ui->groupBoxSelectiveBlurLevels->hide();
Expand Down Expand Up @@ -416,7 +434,8 @@ void FormImageProp::updateComboBoxes(int index){
// color picker
imageProp.colorPickerMethod = (ColorPickerMethod) ui->comboBoxColorPickerMethod->currentIndex();


// grunge blending mode
imageProp.grungeBlendingMode = ui->comboBoxGrungeBlendingMode->currentIndex();
emit imageChanged();
}

Expand Down Expand Up @@ -525,6 +544,21 @@ void FormImageProp::updateGuiSpinBoxesAndLabes(int){
imageProp.normalMixerPosX = ui->horizontalSliderNormalMixerPosX->value()/100.0;
imageProp.normalMixerPosY = ui->horizontalSliderNormalMixerPosY->value()/100.0;

if(imageProp.imageType == GRUNGE_TEXTURE){
imageProp.grungeOverallWeight = ui->horizontalSliderGrungeOverallWeight->value();
imageProp.grungeSeed = ui->horizontalSliderGrungeSeed->value();
imageProp.grungeRadius = ui->horizontalSliderGrungeRadius->value();
}
imageProp.grungeImageWeight = ui->horizontalSliderGrungeImageWeight->value();
imageProp.grungeMainImageWeight = ui->horizontalSliderGrungeMainImageWeight->value();


if(ui->horizontalSliderGrungeOverallWeight->value() == 0){
emit toggleGrungeSettings(false);
}else{
emit toggleGrungeSettings(true);
}

ui->labelNormalMixerScale->setText(QString::number(imageProp.normalMixerScale));
}

Expand Down Expand Up @@ -568,6 +602,12 @@ void FormImageProp::updateGuiCheckBoxes(){
imageProp.bNormalMixerEnabled = ui->checkBoxNormalMixerEnable->isChecked();


if(imageProp.imageType == GRUNGE_TEXTURE){
imageProp.bGrungeEnableRandomTranslations = ui->checkBoxGrungeRandomTranslations->isChecked();
imageProp.bGrungeReplotAllWhenChanged = ui->checkBoxGrungeReplotAllAfterChange->isChecked();
}


if(imageProp.bRoughnessEnableColorPicking){
if(!imageProp.bRoughnessColorPickingToggled)ui->groupBoxGeneral->setDisabled(true);
}else{
Expand Down Expand Up @@ -702,6 +742,34 @@ void FormImageProp::showNormalMixerGroup(){
ui->groupBoxNormalMixer->show();
}

void FormImageProp::showGrungeSettingsGroup(){
ui->groupBoxGrungeSettings->show();
}

void FormImageProp::showGrungeMainImageWeightSlider(){
ui->labelGrungeImageWeight->show();
ui->labelGrungeImageWeight2->show();
ui->horizontalSliderGrungeMainImageWeight->show();
}

void FormImageProp::hideGrungeBlendinModeComboBox(){
ui->comboBoxGrungeBlendingMode->hide();
ui->labelGrungeBlendingMode->hide();
}

void FormImageProp::toggleGrungeImageSettingsGroup(bool toggle){
if(toggle) ui->groupBoxGrungeImageSettings->show();
else ui->groupBoxGrungeImageSettings->hide();
}

void FormImageProp::invertGrunge(bool toggle){

ui->checkBoxInvertB->setChecked(toggle);
ui->checkBoxInvertG->setChecked(toggle);
ui->checkBoxInvertR->setChecked(toggle);
updateGuiCheckBoxes();
}

void FormImageProp::hideOcclusionInputGroup(){
ui->groupBoxOcclusionInputImage->hide();
}
Expand Down Expand Up @@ -862,12 +930,24 @@ void FormImageProp::reloadSettings(){
ui->checkBoxRoughnessColorInvert->setChecked(imageProp.bRoughnessInvertColorMask);
ui->horizontalSliderRoughnessColorOffset->setValue(imageProp.roughnessColorOffset*100);
ui->horizontalSliderRoughnessColorGlobalOffset->setValue(imageProp.roughnessColorGlobalOffset*255);

ui->horizontalSliderRoughnessColorAmplifier->setValue(imageProp.roughnessColorAmplifier*100);

ui->horizontalSliderSelectiveBlurNoIters->setValue(imageProp.selectiveBlurNoIters);
ui->comboBoxColorPickerMethod->setCurrentIndex(imageProp.colorPickerMethod);

// grunge map
ui->horizontalSliderGrungeImageWeight ->setValue(imageProp.grungeImageWeight);
ui->horizontalSliderGrungeMainImageWeight->setValue(imageProp.grungeMainImageWeight);
ui->comboBoxGrungeBlendingMode->setCurrentIndex(imageProp.grungeBlendingMode);
if(imageProp.imageType == GRUNGE_TEXTURE){

//ui->horizontalSliderGrungeOverallWeight ->setValue(imageProp.grungeOverallWeight);
ui->horizontalSliderGrungeRadius ->setValue(imageProp.grungeRadius);
ui->horizontalSliderGrungeSeed ->setValue(imageProp.grungeSeed);
ui->checkBoxGrungeRandomTranslations->setChecked(imageProp.bGrungeEnableRandomTranslations);
}



// input image case study
switch(imageProp.imageType){
case(NORMAL_TEXTURE):
Expand Down
8 changes: 8 additions & 0 deletions Sources/formimageprop.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class FormImageProp : public FormImageBase
void hideSpecularInputGroup();
void hideRoughnessInputGroup();
void showNormalMixerGroup();
void showGrungeSettingsGroup();
void showGrungeMainImageWeightSlider();
void hideGrungeBlendinModeComboBox();


~FormImageProp();
Expand Down Expand Up @@ -79,6 +82,10 @@ public slots:
// normal mixer
void openNormalMixerImage();
void pasteNormalFromClipBoard();

// grunge
void toggleGrungeImageSettingsGroup(bool toggle);
void invertGrunge(bool toggle);
signals:
void reloadSettingsFromConfigFile(TextureTypes type);
void imageChanged();
Expand All @@ -89,6 +96,7 @@ public slots:
void conversionHeightNormalToOcclusionApplied();
void recalculateOcclusion();
void toggleColorPickingApplied(bool toggle);
void toggleGrungeSettings(bool toggle);


private:
Expand Down
Loading

0 comments on commit beb00b7

Please sign in to comment.