32 const uint x_rgt = min(
NX_PADDED-1, x_lft+1u );
33 const uint y_upp = min(
NY_PADDED-1, y_dwn+1u );
36 const float rx_weight = vec[0]-(float)x_lft+(
float)
PAD_WIDTH;
37 const float lx_weight = 1.0f-rx_weight;
38 const float uy_weight = vec[1]-(float)y_dwn+(
float)
PAD_WIDTH;
39 const float dy_weight = 1.0f-uy_weight;
42 const float2 uv_dwn = uv_array[
NY_PADDED*x_lft+y_dwn]*lx_weight
43 + uv_array[
NY_PADDED*x_rgt+y_dwn]*rx_weight;
44 const float2 uv_upp = uv_array[
NY_PADDED*x_lft+y_upp]*lx_weight
45 + uv_array[
NY_PADDED*x_rgt+y_upp]*rx_weight;
48 return fast_normalize(uv_dwn*dy_weight+uv_upp*uy_weight);
85 const uint x_rgt = min(
NX_PADDED-1, x_lft+1u );
86 const uint y_upp = min(
NY_PADDED-1, y_dwn+1u );
89 const float rx_weight = vec[0]-(float)x_lft+(
float)
PAD_WIDTH;
90 const float lx_weight = 1.0f-rx_weight;
91 const float uy_weight = vec[1]-(float)y_dwn+(
float)
PAD_WIDTH;
92 const float dy_weight = 1.0f-uy_weight;
95 const float2 uv_dwn = uv_array[x_lft+
NX_PADDED*y_dwn]*lx_weight
96 + uv_array[x_rgt+
NX_PADDED*y_dwn]*rx_weight;
97 const float2 uv_upp = uv_array[x_lft+
NX_PADDED*y_upp]*lx_weight
98 + uv_array[x_rgt+
NX_PADDED*y_upp]*rx_weight;
101 return fast_normalize(uv_dwn*dy_weight+uv_upp*uy_weight);
147 return ((float2)(compressed_vector[0],
167 (
char)(raw_position[1]*TRAJECTORY_RESOLUTION)
184 dt = select(dt,((
int)(x+1.5f)-(x+0.5f))/u, isgreater(u,0.0f));
186 dt = select(dt,-((x+0.5f)-(
int)(x+0.5f))/u, isless(u,0.0f));
static float2 speed_interpolator(float2 vec, __global const float2 *uv_array)
Bilinearly interpolate a velocity vector (choice of row-major or column-major arrays).
static float2 uncompress(char2 compressed_vector)
Unsquish a byte vector back to a float vector.
static char2 compress(float2 raw_vector)
Squish a float vector into a byte vector for O(<1 pixel) trajectory steps Achieved through scaling by...
#define TRAJECTORY_RESOLUTION
static float dt_to_nearest_edge(float x, float u)
In Euler streamline integration (which is the last step), this function provides the delta time requi...
static float2 approximate(float2 raw_position)
Approximate a float vector at the resolution provided by a scaled byte vector.
static uint get_array_idx(float2 vec)
Compute the array index of the padded grid pixel pointed to by a float2 grid position vector (choice ...