It was the gamma being wrong. Interesting how much different this is working than SFML+OpenCL

master
mitchellhansen 5 years ago
parent 58f5289a3b
commit e476cb2e4e

@ -33,48 +33,48 @@ uint get_idx(int offset_x, int offset_y){
void main() { void main() {
uint idx = get_idx(0,0); 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)]);
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) > 975){
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);
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)]);
// 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) > 275){
// p.x = 0;
// p.y = 0;
// p.z = 255;
// }
// //p.z = max(p.z - (d0.x + d0.y + d0.z + d1.x + d1.y + d1.z)/5, 0);
// 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);
// p.x = 70;
// 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);
// Just gonna keep this around
// read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x000000FF) ) | (p.x); // read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x000000FF) ) | (p.x);
// read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8); // read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8);
// read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x00FF0000) ) | (p.z << 16); // read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0x00FF0000) ) | (p.z << 16);
// read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0xFF000000) ) | (p.w << 24); // read_buffer.buf[idx] = (read_buffer.buf[idx] & (~0xFF000000) ) | (p.w << 24);
}

@ -2,26 +2,15 @@
layout(location = 0) in vec2 tex_coords; layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color; layout(location = 0) out vec4 f_color;
layout(set = 0, binding = 0) uniform sampler2D tex; layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 1, rgba8ui) readonly uniform uimage2D img; layout(set = 0, binding = 1, rgba32ui) readonly uniform uimage2D img;
void main() { void main() {
vec2 onePixel = vec2(1.0, 1.0) / (720.0, 756.0);
vec2 pos = tex_coords * onePixel;
ivec2 ipos = ivec2(pos);
vec4 colorSum = imageLoad(img, ipos);
f_color = colorSum;
// f_color = texture(tex, tex_coords);
// ivec2 t = ivec2(tex_coords.x, tex_coords.y );
ivec2 size = ivec2(gl_FragCoord.x, gl_FragCoord.y); ivec2 size = ivec2(gl_FragCoord.x, gl_FragCoord.y);
//ivec2 size = ivec2(0, 0);
f_color = imageLoad(img, size) / (200); f_color = imageLoad(img, size) / (255.0);
// f_color.w = 0; // f_color.a += 100;
// f_color.r = 75; // f_color = texture(tex, tex_coords);
// f_color.g = 30;
// f_color.b =;
float gamma = 0.5;
f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
} }

@ -78,7 +78,7 @@ fn main() {
processor.compile_kernel(String::from("simple-edge.compute")); processor.compile_kernel(String::from("simple-edge.compute"));
processor.compile_shaders(String::from("simple_texture"), &surface); processor.compile_shaders(String::from("simple_texture"), &surface);
processor.load_buffers(String::from("funky-bird.jpg")); processor.load_buffers(String::from("background.jpg"));
let mut timer = Timer::new(); let mut timer = Timer::new();

@ -487,18 +487,10 @@ impl<'a> VkProcessor<'a> {
self.vertex_buffer = Some(vertex_buffer); self.vertex_buffer = Some(vertex_buffer);
let (texture, tex_future) = { let (texture, tex_future) = {
let image = image::load_from_memory_with_format(include_bytes!("../resources/images/funky-bird.jpg"),
ImageFormat::JPEG).unwrap().to_rgba();
println!("{}", image.len());
println!("{}", self.image_buffer.len());
let dimensions = image.dimensions();
let image_data = image.into_raw().clone();
ImmutableImage::from_iter( ImmutableImage::from_iter(
image_data.iter().cloned(), self.image_buffer.iter().cloned(),
Dimensions::Dim2d { width: dimensions.0, height: dimensions.1 }, Dimensions::Dim2d { width: self.xy.0, height: self.xy.1 },
Format::R8G8B8A8Srgb, Format::R8G8B8A8Srgb,
self.queue.clone() self.queue.clone()
// self.image_buffer.iter().cloned(), // self.image_buffer.iter().cloned(),
@ -508,10 +500,6 @@ impl<'a> VkProcessor<'a> {
}; };
let attachment_image = { let attachment_image = {
let image = image::load_from_memory_with_format(include_bytes!("../resources/images/funky-bird.jpg"),
ImageFormat::JPEG).unwrap().to_rgba();
let dimensions = image.dimensions();
let image_data = image.into_raw().clone();
let mut usage = ImageUsage::none(); let mut usage = ImageUsage::none();
usage.transfer_destination = true; usage.transfer_destination = true;
@ -519,7 +507,7 @@ impl<'a> VkProcessor<'a> {
AttachmentImage::with_usage( AttachmentImage::with_usage(
self.device.clone(), self.device.clone(),
[dimensions.0, dimensions.1], [self.xy.0, self.xy.1],
Format::R8G8B8A8Uint, Format::R8G8B8A8Uint,
usage) usage)
}; };

Loading…
Cancel
Save