removed the colored vertex and combined into one. Half fixed texturing. Fully fixed images and compute swapping

This commit is contained in:
2019-09-10 21:13:48 -07:00
parent e8507f9dfc
commit 9043c2cd3c
13 changed files with 148 additions and 249 deletions

View File

@@ -1,15 +1,16 @@
#version 450
// These come in from the vertex definition
layout(location = 0) in vec2 position;
layout(location = 0) in vec2 v_position;
layout(location = 1) in vec4 color;
layout(location = 2) in vec2 ti_position;
// These are made up in the shader themselves
layout(location = 0) out vec4 out_color;
void main() {
out_color = color;
gl_Position = vec4(position, 0.0, 1.0);
gl_Position = vec4(v_position, 0.0, 1.0);
}

View File

@@ -36,35 +36,35 @@ void main() {
uint idx = get_idx(0,0);
ivec4 p = separate(read_buffer.buf[get_idx(0 , 0)]);
ivec4 p0 = separate(read_buffer.buf[get_idx(0 , 1)]);
ivec4 p1 = separate(read_buffer.buf[get_idx(0 ,-1)]);
ivec4 p2 = separate(read_buffer.buf[get_idx(1 , 1)]);
ivec4 p3 = separate(read_buffer.buf[get_idx(-1,-1)]);
ivec4 p4 = separate(read_buffer.buf[get_idx(1 , 0)]);
ivec4 p5 = separate(read_buffer.buf[get_idx(-1, 0)]);
ivec4 p6 = separate(read_buffer.buf[get_idx(1 ,-1)]);
ivec4 p7 = separate(read_buffer.buf[get_idx(-1, 1)]);
// ivec4 p0 = separate(read_buffer.buf[get_idx(0 , 1)]);
// ivec4 p1 = separate(read_buffer.buf[get_idx(0 ,-1)]);
// ivec4 p2 = separate(read_buffer.buf[get_idx(1 , 1)]);
// ivec4 p3 = separate(read_buffer.buf[get_idx(-1,-1)]);
// ivec4 p4 = separate(read_buffer.buf[get_idx(1 , 0)]);
// ivec4 p5 = separate(read_buffer.buf[get_idx(-1, 0)]);
// ivec4 p6 = separate(read_buffer.buf[get_idx(1 ,-1)]);
// ivec4 p7 = separate(read_buffer.buf[get_idx(-1, 1)]);
//
// ivec3 d0 = abs(p0.xyz - p1.xyz);
// ivec3 d1 = abs(p2.xyz - p3.xyz);
// ivec3 d2 = abs(p4.xyz - p5.xyz);
// ivec3 d3 = abs(p6.xyz - p7.xyz);
//
// ivec3 m = max(max(max(d0, d1), d2), d3);
//
// if ((m.x + m.y + m.z) > 200){
// p.x = 0;
// p.y = 0;
// p.z = 255;
// }
// else {
// //p.w = 125;
// }
ivec3 d0 = abs(p0.xyz - p1.xyz);
ivec3 d1 = abs(p2.xyz - p3.xyz);
ivec3 d2 = abs(p4.xyz - p5.xyz);
ivec3 d3 = abs(p6.xyz - p7.xyz);
ivec3 m = max(max(max(d0, d1), d2), d3);
if ((m.x + m.y + m.z) > 200){
p.x = 0;
p.y = 0;
p.z = 255;
}
else {
//p.w = 125;
}
// write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x000000FF) ) | (p.x);
// write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8);
// write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x00FF0000) ) | (p.z << 16);
// write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0xFF000000) ) | (p.w << 24);
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x000000FF) ) | (p.x);
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8);
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x00FF0000) ) | (p.z << 16);
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0xFF000000) ) | (p.w << 24);
}

View File

@@ -2,7 +2,7 @@
// SIMPLE TEXTURE : FRAGMENT SHADER
// These come in from the previous shader (vertex)
layout(location = 0) in vec2 img_coords;
layout(location = 0) in vec2 position;
// This goes out to the bound image in window_size_dependent setup
layout(location = 0) out vec4 f_color;
@@ -15,8 +15,9 @@ void main() {
ivec2 pos = ivec2(gl_FragCoord.x, gl_FragCoord.y);
f_color = imageLoad(img, ivec2(pos)) / (255.0);
f_color = imageLoad(img, ivec2(position)) / (255.0);
float gamma = 0.5;
f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
}

View File

@@ -2,15 +2,17 @@
// SIMPLE IMAGE : VERTEX SHADER
// These come in from the vertex definition
layout(location = 0) in vec2 position;
layout(location = 0) in vec2 v_position;
layout(location = 1) in vec4 color;
layout(location = 2) in vec2 ti_position;
// These are made up in the shader themselves
layout(location = 0) out vec2 img_coords;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
img_coords = position;
gl_Position = vec4(v_position, 0.0, 1.0);
img_coords = ti_position;
}

View File

@@ -2,7 +2,7 @@
// SIMPLE TEXTURE : FRAGMENT SHADER
// These come in from the previous shader (vertex)
layout(location = 0) in vec2 tex_coords;
layout(location = 0) in vec2 texture_position;
// This goes out to the bound image in window_size_dependent setup
layout(location = 0) out vec4 f_color;
@@ -13,14 +13,9 @@ layout(set = 0, binding = 0) uniform sampler2D tex;
void main() {
ivec2 pos = ivec2(gl_FragCoord.x, gl_FragCoord.y);
ivec2 pixel_pos = ivec2(gl_FragCoord.x, gl_FragCoord.y);
// f_color = imageLoad(img, ivec2(pos)) / (255.0);
//
// float gamma = 0.5;
// f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
f_color = texture(tex, tex_coords);
float gamma = 0.5;
f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
f_color = texture(tex, texture_position);
float gamma = 0.5;
f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
}

View File

@@ -3,16 +3,17 @@
// These come in from the vertex definition
// TODO : Need to add texture coordinate attribute so I can single VBO all these sumbitches
layout(location = 0) in vec2 position;
layout(location = 0) in vec2 v_position;
layout(location = 1) in vec4 color;
layout(location = 2) in vec2 ti_position;
// These are made up in the shader themselves
layout(location = 0) out vec2 tex_coords;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
tex_coords = position;
gl_Position = vec4(v_position, 0.0, 1.0);
tex_coords = ti_position;
}