ogl_beamforming

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

Commit: 8859b7d2eb29a182dfc4aa4f67e3b4f8296e165b
Parent: a368b6148ec8d0204f8ab5c33ee5356fd8681eac
Author: Randy Palamar
Date:   Mon,  9 Sep 2024 19:13:18 -0600

hercules: handle infinite focal_depth (for plane waves)

Diffstat:
Mshaders/hercules.glsl | 26+++++++++++++++++++++-----
Mshaders/uforces.glsl | 3+++
2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/shaders/hercules.glsl b/shaders/hercules.glsl @@ -37,6 +37,9 @@ layout(location = 4) uniform ivec3 u_volume_export_dim_offset; #define C_SPLINE 0.5 +#define TX_ROWS 0 +#define TX_COLS 1 + #if 0 /* NOTE: interpolation is unnecessary if the data has been demodulated and not decimated */ vec2 cubic(uint ridx, float t) @@ -99,16 +102,31 @@ void main() /* NOTE: for I-Q data phase correction */ float iq_time_scale = (lpf_order > 0)? radians(360) * center_frequency : 0; - vec3 starting_dist = vec3(image_point.x - xdc_min_xy.x, image_point.y - xdc_min_xy.y, image_point.z); - vec3 delta = vec3(xdc_size.x / float(dec_data_dim.y), xdc_size.y / float(dec_data_dim.y), 0); + vec3 starting_dist = image_point - vec3(xdc_min_xy.x, xdc_min_xy.y, 0); + vec3 delta = vec3(xdc_size.x, xdc_size.y, 0) / vec3(dec_data_dim.y); float dzsign = sign(image_point.z - focal_depth); /* NOTE: offset correcting for both pulse length and low pass filtering */ - float time_correction = time_offset + (lpf_order + 1) / sampling_frequency; + float time_correction = time_offset + lpf_order / sampling_frequency; vec2 sum = vec2(0); vec3 rdist = starting_dist; + /* TODO: pass this in (there is a problem in that it depends on the orientation + * of the array relative to the target/subject). */ + int transmit_orientation = TX_ROWS; + float transmit_dist; + if (isinf(focal_depth)) { + /* NOTE: plane wave */ + transmit_dist = image_point.z; + } else { + /* NOTE: cylindrical diverging wave */ + if (transmit_orientation == TX_ROWS) + transmit_dist = length(vec2(image_point.y, image_point.z - focal_depth)); + else + transmit_dist = length(vec2(image_point.x, image_point.z - focal_depth)); + } + int direction = beamform_plane * (u_volume_export_pass ^ 1); uint ridx = 0; /* NOTE: For Each Acquistion in Raw Data */ @@ -116,8 +134,6 @@ void main() uint base_idx = (i - uforces) / 4; uint sub_idx = (i - uforces) % 4; - float transmit_dist = image_point.z; - /* NOTE: For Each Virtual Source */ for (uint j = 0; j < dec_data_dim.y; j++) { float dist = transmit_dist + length(rdist); diff --git a/shaders/uforces.glsl b/shaders/uforces.glsl @@ -80,6 +80,9 @@ void main() vec4 output_size = abs(output_max_coord - output_min_coord); vec3 image_point = output_min_coord.xyz + voxel * output_size.xyz / out_data_dim.xyz; + /* TODO: fix the math so that the image plane can be aritrary */ + image_point.y = 0; + /* NOTE: used for constant F# dynamic receive apodization. This is implemented as: * * / |x_e - x_i|\