Godot Version
Godot 4.3
Question
I have written a simple compute shader
#[compute]
#version 450
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(set = 0, binding = 0, std430) restrict buffer IO {
bool Corners[16][16];
uint Valtable[16][16];
}
IO;
void main() {
uint x = gl_GlobalInvocationID.x;
uint y = gl_GlobalInvocationID.y;
uint value = 0;
if (x == 15 || y == 15)
value = 0;
else
value = IO.Corners[x][y] * 1 + IO.Corners[x + 1][y] * 2 + IO.Corners[x][y + 1] * 4 + IO.Corners[x + 1][y + 1] * 8;
IO.Valtable[x][y] = value;
}
However godot gives me this error at the bottom of the screen
Does anyone know how to fix this?
It looks like you have written a simple shader in a shader language other than Godot’s version of GLSL 3.0. I’m unfamiliar with layout(), and I’m unfamiliar with your comment headers. Also I’m not sure what IO stands for, but I’m guessing you need to use the GLSL equivalent.
IO is just the name for the input buffer. Layout is used in glsl, which godot utilizes for compute shaders.
Anyways, I figured out that the buffer name in layout() and the one following it needs to be different as so:
#[compute]
#version 450
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(set = 0, binding = 0, std430) restrict buffer bufferData {
bool Corners[16][16];
uint Valtable[16][16];
}
buff;
void main() {
uint x = gl_GlobalInvocationID.x;
uint y = gl_GlobalInvocationID.y;
uint value = 0;
if (x == 15 || y == 15)
value = 0;
else
value = int(buff.Corners[x][y]) * 1 + int(buff.Corners[x + 1][y]) * 2 + int(buff.Corners[x][y + 1]) * 4 + int(buff.Corners[x + 1][y + 1]) * 8;
buff.Valtable[x][y] = value;
}
1 Like
Cool. I learned something new.
system
Closed
March 11, 2025, 9:29pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.