aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-22 23:23:30 +0100
committerAndreas Grois <andi@grois.info>2018-03-22 23:23:30 +0100
commit81863349bfc7fede772eac9b6fd8024f49380e42 (patch)
treeb4cafd7a04db93591f44121750f1b92369b6eeb3
parente45b39dc2ebb76bc079677b1d186b6a5109d1a5b (diff)
Make preview use color scale and gamma
-rw-r--r--BuddhaTest/Shaders/BuddhaCompute.glsl3
-rw-r--r--BuddhaTest/Shaders/BuddhaFragment.glsl4
-rw-r--r--BuddhaTest/src/BuddhaTest.cpp5
3 files changed, 11 insertions, 1 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl
index dfc3828..12ed6e8 100644
--- a/BuddhaTest/Shaders/BuddhaCompute.glsl
+++ b/BuddhaTest/Shaders/BuddhaCompute.glsl
@@ -12,6 +12,7 @@ layout(std430, binding=3) restrict buffer brightnessData
restrict uint brightness;
};
+/** Data stored in the state buffer. */
struct individualData
{
uint phase;
@@ -33,6 +34,7 @@ uniform uvec4 orbitLength;
uniform uint iterationsPerDispatch;
uniform uint totalIterations;
+/** Data stored in shared memory. Used to reduce register pressure. Read at beginning, written back at end. */
struct workerState
{
uint phase;
@@ -42,6 +44,7 @@ struct workerState
uint brightness;
};
+/** Storage in shared memory. Used to reduce register pressure. */
shared workerState[gl_WorkGroupSize.x*gl_WorkGroupSize.y*gl_WorkGroupSize.z] localStore;
void uintMaxIP(inout uint modified, const uint constant)
diff --git a/BuddhaTest/Shaders/BuddhaFragment.glsl b/BuddhaTest/Shaders/BuddhaFragment.glsl
index 73cb53e..52a0354 100644
--- a/BuddhaTest/Shaders/BuddhaFragment.glsl
+++ b/BuddhaTest/Shaders/BuddhaFragment.glsl
@@ -15,6 +15,8 @@ layout(std430, binding=3) restrict readonly buffer brightnessData
uniform uint width;
uniform uint height;
+uniform float gamma;
+uniform float colorScale;
uvec3 getColorAt(vec2 fragCoord)
{
@@ -27,6 +29,6 @@ uvec3 getColorAt(vec2 fragCoord)
void main(){
uvec3 totalCount = getColorAt(uv);
- vec3 scaled = vec3(totalCount)/max(float(brightness),1.0);
+ vec3 scaled = pow(min(vec3(1.0),colorScale*vec3(totalCount)/max(float(brightness),1.0)),vec3(gamma));
color = scaled;
}
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp
index 4d7ab9f..3af5f44 100644
--- a/BuddhaTest/src/BuddhaTest.cpp
+++ b/BuddhaTest/src/BuddhaTest.cpp
@@ -163,8 +163,13 @@ int main(int argc, char * argv[])
glUseProgram(VertexAndFragmentShaders);
GLint widthUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "width");
GLint heightUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "height");
+ GLint gammaUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "gamma");
+ GLint colorScaleUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "colorScale");
glUniform1ui(widthUniformFragmentHandle, settings.imageWidth);
glUniform1ui(heightUniformFragmentHandle, bufferHeight);
+ glUniform1f(gammaUniformFragmentHandle, settings.pngGamma);
+ glUniform1f(colorScaleUniformFragmentHandle,settings.pngColorScale);
+
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
uint32_t iterationsPerFrame = 1;