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;
glBindTexture(GL_TEXTURE_2D, _buffer);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, width, height);
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.

enter image description here

Low resolution image: enter image description here

  • 1
    \$\begingroup\$ Weird! It looks like depth-fighting, but that shouldn't apply to a compute shader, I wouldn't think. \$\endgroup\$ Aug 25, 2019 at 18:04
  • \$\begingroup\$ @user1118321 No, in fact you can even have situations where GLSL code will z-fight, but a plain OpenGL version doesn't: example. I do agree that it looks very much like z-fighting and not aliasing. \$\endgroup\$
    – Pikalek
    Aug 26, 2019 at 3:24


You must log in to answer this question.

Browse other questions tagged .