You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
#version 450
|
|
|
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
layout(set = 0, binding = 0) buffer Data {
|
|
int data[];
|
|
} data;
|
|
|
|
//layout(set = 0, binding = 1) buffer Settings {
|
|
// int settings[];
|
|
//} settings;
|
|
|
|
ivec4 separate(int pix){
|
|
ivec4 r = ivec4(
|
|
(pix & 0x000000FF),
|
|
(pix & 0x0000FF00) >> 8,
|
|
(pix & 0x00FF0000) >> 16,
|
|
(pix & 0xFF000000) >> 24
|
|
);
|
|
return r;
|
|
}
|
|
|
|
uint get_idx(int offset_x, int offset_y){
|
|
|
|
// uint x = min(settings.settings[0], max(0, gl_GlobalInvocationID.x + offset_x));
|
|
// uint y = min(settings.settings[1], max(0, gl_GlobalInvocationID.y + offset_y));
|
|
// return ((y * settings.settings[0]) + x);
|
|
|
|
uint x = min(800, max(0, gl_GlobalInvocationID.x + offset_x));
|
|
uint y = min(600, max(0, gl_GlobalInvocationID.y + offset_y));
|
|
return ((y * 800) + x);
|
|
}
|
|
|
|
void main() {
|
|
|
|
uint idx = get_idx(0,0);
|
|
|
|
ivec4 p = separate(data.data[get_idx(0,0)]);
|
|
|
|
|
|
ivec4 p0 = separate(data.data[get_idx(2,0)]);
|
|
ivec4 p1 = separate(data.data[get_idx(-2,0)]);
|
|
|
|
ivec4 p2 = separate(data.data[get_idx(0,2)]);
|
|
ivec4 p3 = separate(data.data[get_idx(0,-2)]);
|
|
|
|
ivec3 d0 = abs(p0.xyz - p1.xyz);
|
|
ivec3 d1 = abs(p2.xyz - p3.xyz);
|
|
|
|
p.x = 255;//d0.x + d0.y + d0.z + d1.x + d1.y + d1.z;
|
|
|
|
data.data[idx] = (data.data[idx] & (~0x000000FF) ) | (p.x);
|
|
data.data[idx] = (data.data[idx] & (~0x0000FF00) ) | (p.y << 8);
|
|
data.data[idx] = (data.data[idx] & (~0x00FF0000) ) | (p.z << 16);
|
|
data.data[idx] = (data.data[idx] & (~0xFF000000) ) | (p.w << 24);
|
|
|
|
} |