Skip to content

Commit

Permalink
Signed <> Unsigned conversion for non Normals
Browse files Browse the repository at this point in the history
Fix for missed Signed <> Unsigned conversion for non Normals textures.
This conversion map [-1 +1] range to [0 +1] range and [0 +1] to [-1 +1]
  • Loading branch information
ssh4net committed Dec 4, 2023
1 parent f82271c commit 55c27ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Solidify/src/UI.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,22 @@ void MainWindow::rngSettings() {
if (action == rng_Unsg) {
settings.rangeMode = 0;
emit updateTextSignal("Unsigned floats");
qDebug() << "32/16 bit float Normals are in [0.0 ~ 1.0] range";
qDebug() << "32/16 bit floats are in [0.0 ~ 1.0] range";
}
else if (action == rng_Sign) {
settings.rangeMode = 1;
emit updateTextSignal("Signed floats");
qDebug() << "32/16 bit floats Normals are in [-1.0 ~ 1.0] range";
qDebug() << "32/16 bit floats are in [-1.0 ~ 1.0] range";
}
else if (action == rng_SU) {
settings.rangeMode = 2;
emit updateTextSignal("Signed <> Unsigned");
qDebug() << "32/16 bit floats Normals are in [-1.0 ~ 1.0] range converted to [0.0 ~ 1.0]";
}
else if (action == rng_US) {
settings.rangeMode = 3;
settings.rangeMode = 2;
emit updateTextSignal("Unsigned <> Signed");
qDebug() << "32/16 bit floats Normals are in [0.0 ~ 1.0] range converted to [-1.0 ~ 1.0]";
qDebug() << "32/16 bit floats range [0.0 ~ 1.0] map to a [-1.0 ~ 1.0]";
}
else if (action == rng_SU) {
settings.rangeMode = 3;
emit updateTextSignal("Signed <> Unsigned");
qDebug() << "32/16 bit floats range [-1.0 ~ 1.0] map to a [0.0 ~ 1.0]";
}
}

Expand Down
12 changes: 12 additions & 0 deletions Solidify/src/solidify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ bool solidify_main(const std::string& inputFileName, const std::string& outputFi
LOG(info) << "Normalize skipped\n";
}

// if not normalize and not repair and range conversion is needed
if (settings.repairMode == 0 && !doNormalize && settings.rangeMode > 1) {
switch (settings.rangeMode) {
case 2: // 2 - unsigned -> signed
out_buf = ImageBufAlgo::mad(out_buf, 2.0f, -1.0f);
break;
case 3: // 3 - signed -> unsigned
out_buf = ImageBufAlgo::mad(out_buf, 0.5f, 0.5f);
break;
}
}

ImageSpec& ospec = out_buf.specmod();
if (settings.alphaMode == 1) {
ospec.nchannels = grayscale ? 2 : 4; // Write RGB and alpha channels
Expand Down
2 changes: 1 addition & 1 deletion Solidify/src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "processing.h"

#define VERSION_MAJOR 1
#define VERSION_MINOR 38
#define VERSION_MINOR 39

void setPBarColor(QProgressBar* progressBar, const QColor& color = QColor("#05B8CC"));

Expand Down

0 comments on commit 55c27ce

Please sign in to comment.