Debian Codegraph @

tests/manual/rhi/computeimage/image.comp

raw
1 #version 440
2
3 layout (local_size_x = 16, local_size_y = 16) in;
4
5 layout(std140, binding = 0) uniform UniformBuffer
6 {
7 float factor;
8 } ubuf;
9
10 layout (binding = 1, rgba8) uniform readonly image2D texIn;
11 layout (binding = 2, rgba8) uniform writeonly image2D texOut;
12
13 void main()
14 {
15 ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
16 ivec2 d = ivec2(1, 1);
17 vec4 diff = imageLoad(texIn, pos + d) - imageLoad(texIn, pos - d);
18 float c = (diff.x + diff.y + diff.z) / ubuf.factor + 0.5f;
19 imageStore(texOut, pos, vec4(c, c, c, 1.0));
20 }