I have the following compute shader reading data from iimage2D and replacing the data based on its color value. The problem here I face is that though I read data in integer format and write back in integer the written data is interpreted as float value between 0 to 1. Hence getting unexpected output.
Following is the Compute shader:
layout(rgba32i) coherent uniform iimage2D i_image2D;
layout (local_size_x = 1, local_size_y = 1) in;
void main()
{
ivec2 idx = ivec2(gl_GlobalInvocationID.xy);
ivec4 readTexel = imageLoad(i_image2D, idx);
if(readTexel[0] == 0 && readTexel[1] == 2147483647 && readTexel[2] == 0 && readTexel[3] == 2147483647)
{
readTexel = ivec4(2147483647,0,0,2147483647);
}
else
{
readTexel = ivec4(0,2147483647,0,2147483647);
}
imageStore(i_image2D, idx, readTexel);
}