diff options
Diffstat (limited to 'flowy/src/motion/enc.wgsl')
-rw-r--r-- | flowy/src/motion/enc.wgsl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/flowy/src/motion/enc.wgsl b/flowy/src/motion/enc.wgsl new file mode 100644 index 0000000..cc185e9 --- /dev/null +++ b/flowy/src/motion/enc.wgsl @@ -0,0 +1,49 @@ + +struct Params { + block_size: vec2<i32>, + output_stride: i32 +} + +struct BlockOffset { + score: f32, + offset: vec2<i32>, +} + +@group(0) @binding(0) var<uniform> params: Params; +@group(0) @binding(1) var<storage, read_write> output: BlockOffset; +@group(0) @binding(2) var prev: texture_2d<f32>; +@group(0) @binding(3) var next: texture_2d<f32>; + +@compute @workgroup_size(1) fn main(@builtin(global_invocation_id) global_id: vec3<u32>) { + let uv = vec2<i32>(global_id.xy) * params.block_size; + + // output[global_id.x + global_id.y * params.output_stride] = BlockOffset(0., uv); + + // let orig = textureLoad(texa, uv, 0); + + // var best_sim = 1000.; + // var best_coord = vec2(0,0); + // for (var x = -SDIST; x <= SDIST; x++) { + // for (var y = -SDIST; y <= SDIST; y++) { + // let ov = uv + vec2(x,y); + // let samp = textureLoad(texb, ov, 0); + // let d = distance(samp.rgb, orig.rgb) + // + distance(sampnn.rgb, orignn.rgb) + // + distance(sampnp.rgb, orignp.rgb) + // + distance(samppn.rgb, origpn.rgb) + // + distance(samppp.rgb, origpp.rgb); + // if d < best_sim { + // best_sim = d; + // best_coord = vec2(x,y); + // } + // }} + + // let col = vec4(colormap_vec(vec2<f32>(best_coord) / f32(SDIST)), 1.); + + // textureStore(output, global_id.xy, col); +} + +// fn colormap_vec(v: vec2<f32>) -> vec3<f32> { +// return vec3(v.y, v.x - 0.5 * v.y, -v.x - 0.5 * v.y); +// } + |