Godot Version
4.7
Question
Hi,
I need help getting compute shaders to compile, would be appreciated, cheers.
I am trying to find the min and max values in an array using a compute shader, but I can’t get this to compile - this is my first glsl compute shader, it is very basic, this is a fundamental reduction algorithm that i need to use in offline processing, so far from optimal. The shader window shows this when i click in the file browser
ERROR: 0:14: '=' : cannot convert from ' temp highp 2-component vector of uint' to ' temp highp 2-component vector of int'
ERROR: 0:14: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
input texture is 512 * 512, global work group size is (64,64,1), local group size (4,4,1), shared memory size, 16.
#[compute]
#version 450
layout(set = 0, binding = 0, rgba8) uniform readnly image2D sourceImage;
layout(set = 0, binding = 1, rgba8) uniform writeonly image2D colorImage;
layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in;
shared int sdata[16];
void main() {
ivec2 UV = gl_GlobalInvocationID.xy;
ivec2 UV_out = ivec2( int( float(UV.x) / 4.0), int( float(UV.y) / 4.0) );
uint local_index = gl_LocalInvocationID.x + gl_LocalInvocationID.y * 4;
sdata[local_index] = (int)imageLoad(sourceImage, UV, ivec2(0, 0), ivec2(511, 511) ).r;
memoryBarrierShared();
barrier();
int min_h =10000.0;
int max_h = -10000.0;
for(uint i = 0; i<16; i++){
if( sdata[i] > max_h ){
max_h = sdata[i];
}
if( sdata[i] < min_h ){
min_h = sdata[i];
}
}
ivec4 output = ivec4( uint(min_h), uint(max_h), 0,0);
imageStore(colorImage, UV_out, output);
}

