aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest
diff options
context:
space:
mode:
Diffstat (limited to 'BuddhaTest')
-rw-r--r--BuddhaTest/include/Helpers.h2
-rw-r--r--BuddhaTest/src/BuddhaTest.cpp3
-rw-r--r--BuddhaTest/src/Helpers.cpp6
3 files changed, 6 insertions, 5 deletions
diff --git a/BuddhaTest/include/Helpers.h b/BuddhaTest/include/Helpers.h
index e4b7ffd..a25aa31 100644
--- a/BuddhaTest/include/Helpers.h
+++ b/BuddhaTest/include/Helpers.h
@@ -9,7 +9,7 @@ namespace Helpers
GLuint LoadShaders(const char * vertex_file_path, const char * fragment_file_path);
GLuint LoadComputeShader(const char * compute_file_path, unsigned int localSizeX, unsigned int localSizeY, unsigned int localSizeZ);
- void WriteOutputPNG(const std::vector<uint32_t>& data, unsigned int width, unsigned int bufferHeight, double gamma);
+ void WriteOutputPNG(const std::vector<uint32_t>& data, unsigned int width, unsigned int bufferHeight, double gamma, double colorScale);
/** Wraps around a C file descriptor. Libpng could be taught to use C++ streams, but I'm too lazy and rather wrap this ugly thing up, so it gets cleaned... */
class ScopedCFileDescriptor
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp
index 9ac6ae3..32bd927 100644
--- a/BuddhaTest/src/BuddhaTest.cpp
+++ b/BuddhaTest/src/BuddhaTest.cpp
@@ -30,6 +30,7 @@ int main()
unsigned int globalWorkGroupSizeZ = 1;
double pngGamma = 1.0;
+ double pngColorScale = 2.0;
GLFWwindow* window;
@@ -183,7 +184,7 @@ int main()
{
std::vector<uint32_t> readBackBuffer(pixelCount);
glGetBufferSubData(GL_SHADER_STORAGE_BUFFER,4*2,4 * pixelCount,readBackBuffer.data()); //offset of 2*4, that's the dimension integers.
- Helpers::WriteOutputPNG(readBackBuffer,bufferWidth,bufferHeight, pngGamma);
+ Helpers::WriteOutputPNG(readBackBuffer,bufferWidth,bufferHeight, pngGamma, pngColorScale);
}
//a bit of cleanup
diff --git a/BuddhaTest/src/Helpers.cpp b/BuddhaTest/src/Helpers.cpp
index bde6b8a..eacaf5d 100644
--- a/BuddhaTest/src/Helpers.cpp
+++ b/BuddhaTest/src/Helpers.cpp
@@ -155,7 +155,7 @@ namespace Helpers
return ProgramID;
}
- void WriteOutputPNG(const std::vector<uint32_t>& data, unsigned int width, unsigned int bufferHeight, double gamma)
+ void WriteOutputPNG(const std::vector<uint32_t>& data, unsigned int width, unsigned int bufferHeight, double gamma, double colorScale)
{
std::vector<png_byte> pngData(3*width*2*bufferHeight);
std::vector<png_byte *> rows{2*bufferHeight};
@@ -171,9 +171,9 @@ namespace Helpers
}
for(unsigned int i = 0; i < data.size();++i)
{
- if(fabs(gamma - 1.0) > 0.0001)
+ if(fabs(gamma - 1.0) > 0.0001 || fabs(colorScale - 1.0) > 0.0001)
{
- pngData[data.size() + i] = 255.0 * pow(static_cast<double>(data[i])/static_cast<double>(maxValue),gamma);
+ pngData[data.size() + i] = 255.0 * pow(std::min(1.0,colorScale*static_cast<double>(data[i])/static_cast<double>(maxValue)),gamma);
}
else
{