ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | LICENSE

Commit: 309a9a4de94cac0cdbfa0e0b8964b2b24df78936
Parent: 9286c1b99ad08d36463fac13ec6eecf88008d25b
Author: Randy Palamar
Date:   Tue, 10 Dec 2024 11:19:48 -0700

calculate transmit distance relative to world space

For uFORCES it is relative to the transducer surface so we need
the transform but other methods don't care.

Diffstat:
Mshaders/das.glsl | 21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/shaders/das.glsl b/shaders/das.glsl @@ -54,7 +54,7 @@ vec3 calc_image_point(vec3 voxel) { ivec3 out_data_dim = imageSize(u_out_data_tex); vec4 output_size = abs(output_max_coord - output_min_coord); - vec4 image_point = vec4(output_min_coord.xyz + voxel * output_size.xyz / out_data_dim, 1); + vec3 image_point = output_min_coord.xyz + voxel * output_size.xyz / out_data_dim; switch (das_shader_id) { case DAS_ID_UFORCES: @@ -67,10 +67,7 @@ vec3 calc_image_point(vec3 voxel) break; } - - /* NOTE: move the image point into xdc space */ - image_point = u_xdc_transform * image_point; - return image_point.xyz; + return image_point; } vec2 apodize(vec2 value, float apodization_arg, float distance) @@ -80,6 +77,11 @@ vec2 apodize(vec2 value, float apodization_arg, float distance) return value * a * a; } +vec3 row_column_point_scale(bool tx_rows) +{ + return vec3(float(!tx_rows), float(tx_rows), 1); +} + float sample_index(float distance) { float time = distance / speed_of_sound + time_offset; @@ -92,6 +94,9 @@ vec2 HERCULES(vec3 image_point, vec3 delta, uint starting_offset, float apodizat * of the array relative to the target/subject). */ int transmit_orientation = TX_ROWS; float transmit_dist; + vec3 transmit_point = image_point * row_column_point_scale(transmit_orientation == TX_ROWS); + vec3 recieve_point = (u_xdc_transform * vec4(image_point, 1)).xyz; + if (isinf(focal_depth)) { /* NOTE: plane wave */ transmit_dist = image_point.z; @@ -104,7 +109,7 @@ vec2 HERCULES(vec3 image_point, vec3 delta, uint starting_offset, float apodizat } uint ridx = starting_offset; - vec3 rdist = image_point; + vec3 rdist = recieve_point; int direction = beamform_plane * (u_volume_export_pass ^ 1); vec2 sum = vec2(0); @@ -123,7 +128,7 @@ vec2 HERCULES(vec3 image_point, vec3 delta, uint starting_offset, float apodizat ridx += dec_data_dim.x; } - rdist[direction] = image_point[direction]; + rdist[direction] = recieve_point[direction]; rdist[direction ^ 1] -= delta[direction ^ 1]; } return sum; @@ -135,6 +140,8 @@ vec2 uFORCES(vec3 image_point, vec3 delta, uint starting_offset, float apodizati uint uforces = uint(dec_data_dim.y != dec_data_dim.z); uint ridx = starting_offset + dec_data_dim.y * dec_data_dim.x * uforces; + image_point = (u_xdc_transform * vec4(image_point, 1)).xyz; + vec2 sum = vec2(0); for (uint i = uforces; i < dec_data_dim.z; i++) { uint base_idx = (i - uforces) / 4;