coherency_weighting.glsl (1418B)
1 /* See LICENSE for license details. */ 2 layout(std430, buffer_reference, buffer_reference_align = 8) restrict buffer Int16 { 3 int16_t values[]; 4 }; 5 6 layout(std430, buffer_reference, buffer_reference_align = 8) restrict buffer Int16Complex { 7 i16vec2 values[]; 8 }; 9 10 layout(std430, buffer_reference, buffer_reference_align = 8) restrict buffer Float32 { 11 float values[]; 12 }; 13 14 layout(std430, buffer_reference, buffer_reference_align = 8) restrict buffer Float32Complex { 15 vec2 values[]; 16 }; 17 18 #if InputDataKind == DataKind_Float32 19 #define COHERENT_SAMPLE(index) Float32(left_side_buffer).values[index] 20 #define INCOHERENT_SAMPLE(index) Float32(right_side_buffer).values[index] 21 #elif InputDataKind == DataKind_Float32Complex 22 #define COHERENT_SAMPLE(index) Float32Complex(left_side_buffer).values[index] 23 #define INCOHERENT_SAMPLE(index) Float32(right_side_buffer).values[index] 24 #else 25 #error DataKind unsupported for CoherencyWeighting 26 #endif 27 28 uint32_t output_index(uint32_t x, uint32_t y, uint32_t z) 29 { 30 uint32_t result = output_size_x * output_size_y * z + output_size_x * y + x; 31 return result; 32 } 33 34 void main() 35 { 36 uvec3 out_voxel = gl_GlobalInvocationID; 37 if (!all(lessThan(out_voxel, uvec3(output_size_x, output_size_y, output_size_z)))) 38 return; 39 uint32_t index = output_index(out_voxel.x, out_voxel.y, out_voxel.z); 40 COHERENT_SAMPLE(index) *= scale * COHERENT_SAMPLE(index) / INCOHERENT_SAMPLE(index); 41 }