ogl_beamforming

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

Commit: bfbc91602b0cfa4d145965abe31ec1e4f8542ed6
Parent: 10ed09538cfda54285e3a7f3608fc45e31c1a233
Author: Randy Palamar
Date:   Tue, 29 Jul 2025 07:02:17 -0600

shaders/das: make it clear that the relevant iq focus time is fractional

You cannot pre-rotate the IQ samples back up to the demodulation
frequency because the most important part of rotation is the
fractional amount. Without this fractional component you will not
get a coherent summation (the signals will appear "out of focus").

Diffstat:
Mshaders/das.glsl | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/shaders/das.glsl b/shaders/das.glsl @@ -33,7 +33,7 @@ vec2 rotate_iq(vec2 iq, float time) } /* NOTE: See: https://cubic.org/docs/hermite.htm */ -vec2 cubic(int base_index, float x) +vec2 cubic(int base_index, float t) { mat4 h = mat4( 2, -3, 0, 1, @@ -42,17 +42,14 @@ vec2 cubic(int base_index, float x) 1, -1, 0, 0 ); - int xk = int(floor(x)); - float t = x - floor(x); - vec4 S = vec4(t * t * t, t * t, t, 1); - vec2 samples[4] = { - rf_data[base_index + xk - 1], - rf_data[base_index + xk + 0], - rf_data[base_index + xk + 1], - rf_data[base_index + xk + 2], + rf_data[base_index - 1], + rf_data[base_index + 0], + rf_data[base_index + 1], + rf_data[base_index + 2], }; + vec4 S = vec4(t * t * t, t * t, t, 1); vec2 P1 = samples[1]; vec2 P2 = samples[2]; vec2 T1 = C_SPLINE * (P2 - samples[0]); @@ -67,9 +64,10 @@ vec2 sample_rf(int channel, int transmit, float index) { vec2 result = vec2(index >= 0.0f) * vec2(int(index) + 2 * int(interpolate) < dec_data_dim.x); int base_index = channel * dec_data_dim.x * dec_data_dim.z + transmit * dec_data_dim.x; - if (interpolate) result *= cubic(base_index, index); + float tk, t = modf(index, tk); + if (interpolate) result *= cubic(base_index + int(tk), t); else result *= rf_data[base_index + int(round(index))]; - result = rotate_iq(result, index / sampling_frequency); + result = rotate_iq(result, t / sampling_frequency); return result; }