14 |
{ |
{ |
15 |
int row = get_global_id(0), col = get_global_id(1); |
int row = get_global_id(0), col = get_global_id(1); |
16 |
|
|
17 |
if(row < 200 && col < 200) |
if(row <= 200 && col <= 200) |
18 |
{ |
{ |
|
int i; |
|
19 |
float t,x,y,z,probedVal, maxValue = -INFINITY; |
float t,x,y,z,probedVal, maxValue = -INFINITY; |
20 |
float4 t_i, t_j, t_k, value, f, imgPt, pt, v; |
float4 t_i, t_j, t_k, value, f, imgPt, pt, v, nf; |
21 |
int4 n1; |
int4 n1; |
22 |
int4 n; |
int4 n; |
23 |
|
|
27 |
float4 a = (float4) (h2[3],h1[3],h1[3],h2[3]); |
float4 a = (float4) (h2[3],h1[3],h1[3],h2[3]); |
28 |
|
|
29 |
float4 pos = orig + (float)row * rVec + (float)col * cVec; |
float4 pos = orig + (float)row * rVec + (float)col * cVec; |
30 |
float4 dir = (pos - eyeVector) / fabs(pos - eyeVector); |
float4 dir = normalize(pos - eyeVector); |
31 |
float4 NSize = (float4) ((float)height,(float)length,(float)width,1.0f); |
float4 NSize = (float4) ((float)height,(float)length,(float)width,1.0f); |
32 |
|
|
33 |
pt.w = 1.0f; |
for(t = 0.0; t < 40; t+= stepSize) |
|
pos.w = 1.0f; |
|
|
dir.w = 1.0f; |
|
|
value.w = 1.0f; |
|
|
|
|
|
for(t = 0.0; t < 20; t+= stepSize) |
|
34 |
{ |
{ |
35 |
|
|
36 |
pos = pos + stepSize * dir; |
pos = pos + stepSize * dir; |
43 |
dot(pos,transformMatrix.s89ab), |
dot(pos,transformMatrix.s89ab), |
44 |
dot(pos,transformMatrix.scdef)); |
dot(pos,transformMatrix.scdef)); |
45 |
|
|
46 |
|
nf = floor(imgPt); |
47 |
f.xyzw = (float4) (modf(imgPt.x,&x),modf(imgPt.y,&y),modf(imgPt.z,&z),1.0f); |
f = imgPt - nf; |
48 |
|
n1 = convert_int4(nf); |
|
n1 = (int4) ((int)x,(int)y,(int)z,1.0f); |
|
49 |
|
|
50 |
if( (imgPt.x > 1 && imgPt.x < NSize.x - 2) && |
if( (imgPt.x > 1 && imgPt.x < NSize.x - 2) && |
51 |
(imgPt.y > 1 && imgPt.y < NSize.y - 2) && |
(imgPt.y > 1 && imgPt.y < NSize.y - 2) && |
52 |
(imgPt.z > 1 && imgPt.z < NSize.z - 2)) |
(imgPt.z > 1 && imgPt.z < NSize.z - 2)) |
53 |
{ |
{ |
|
|
|
|
|
|
|
|
|
54 |
// the t value for h(fx - i) |
// the t value for h(fx - i) |
55 |
t_i = (float4) (-1.0 - f.x, -f.x,f.x - 1.0, f.x - 2.0); |
float4 t_i = (float4) (-1.0 - f.x, -f.x, f.x - 1.0, f.x - 2.0); |
|
|
|
56 |
// the t value for h(fy - j) |
// the t value for h(fy - j) |
57 |
t_j = (float4) (-1.0 - f.y, -f.y, f.y - 1.0,f.y - 2.0); |
float4 t_j = (float4) (-1.0 - f.y, -f.y, f.y - 1.0, f.y - 2.0); |
58 |
|
float4 t_k = (float4) (-1.0 - f.z, -f.z, f.z - 1.0, f.z - 2.0); |
59 |
// the t value for h(fx - k) |
float tx[4], ty[4]; |
60 |
t_k = (float4) (-1.0 - f.z, -f.z, f.z - 1.0,f.z - 2.0); |
for (int i = -1; i <= 2; i++) { |
61 |
|
for (int j = -1; j <= 2; j++) { |
62 |
|
// compute z axis using vectors |
63 |
value = ( (d + t_i * (c + t_i * (b + t_i * a))) * // h(fx - i) * |
v = (float4)( |
64 |
(d + t_j * (c + t_j * (b + t_j * a))) * // h(fy - j) * |
img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z-1], |
65 |
(d + t_k * (c + t_k * (b + t_k * a)))); // h(fz - k) |
img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z], |
66 |
|
img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z+1], |
67 |
|
img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z+2]); |
68 |
n = (int4) (((n1.x-1) * length * width + n1.y-1 * width + n1.z-1), |
ty[j+1] = dot(v, d + t_k * (c + t_k * (b + t_k * a))); |
69 |
(n1.x * length * width + n1.y * width + n1.z), |
} |
70 |
((n1.x+1) * length * width + n1.y+1 * width + n1.z+1), |
tx[i+1] = dot((float4)(ty[0], ty[1], ty[2], ty[3]), d + t_j * (c + t_j * (b + t_j * a))); |
71 |
((n1.x+2) * length * width + n1.y+2 * width + n1.z+2)); |
} |
72 |
|
probedVal = dot((float4)(tx[0],tx[1],tx[2],tx[3]), d + t_i * (c + t_i * (b + t_i * a))); |
|
|
|
|
|
|
|
v = (float4)(img[n.x], |
|
|
img[n.y], |
|
|
img[n.z], |
|
|
img[n.w]); |
|
|
|
|
|
|
|
|
probedVal = dot(v,value); // V(n + <i,j,k>) * summations of the h(x) components |
|
|
|
|
73 |
|
|
74 |
|
if ((row == 100) && (col == 100)) |
75 |
|
printf("%f %f %f\n", t, f.z, probedVal); |
76 |
// End Probe Operation |
// End Probe Operation |
77 |
if(maxValue < probedVal) |
if(maxValue < probedVal) |
78 |
maxValue = probedVal; |
maxValue = probedVal; |
80 |
} |
} |
81 |
if(row == 0 && col == 74) |
if(row == 0 && col == 74) |
82 |
printf("Max Value: %f\n", maxValue ); |
printf("Max Value: %f\n", maxValue ); |
83 |
out[row * 200 + col] = maxValue; |
out[row * 201 + col] = maxValue; |
84 |
} |
} |
85 |
} |
} |