I'm trying to generate a macbeth chart using the compute shader, but there seems to be an issue with the output image.
here is the glsl code:
#version 430 core
layout (local_size_x = 32, local_size_y = 32) in;
layout (rgba32f, binding=0) uniform image2D data;
uniform int factor = 2;
const float colorMatchingFunc[3][72];
const float spectralData[24][36];
void spectrumToXYZ(uint colorIndex, out vec3 XYZ);
const mat3 XYZ_TO_RGB;
const float gamma = 1;
void main(void){
uvec2 dim = gl_NumWorkGroups.xy/factor;
uvec2 ij = gl_WorkGroupID.xy/factor;
uint i = ij.x + dim.x * ij.y;
vec3 xyz;
spectrumToXYZ(i, xyz);
vec3 rgb = max(vec3(0), XYZ_TO_RGB * xyz);
rgb = pow(rgb, vec3(1/gamma));
imageStore(data, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1));
}
and here is the c++ setup
static int factor = 4;
static int patchSize = 32;
int width = 192 * factor;
int height = 128 * factor;
glActiveTexture(TEXTURE(_id));
glBindTexture(GL_TEXTURE_2D, _buffer);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, width, height);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDispatchCompute(_width / (patchSize), _height / (patchSize), 1);
This setup and glsl code makes sure I get a 6 * 4 macbeth chart.
I'm assuming regardless of which invocation/workgroup I end up in I should always generate the correct color for the patch I'm currently on. but I seem to have som aliasing especially on the bottom row and its very noticable all rows on lower resolutions.