SHOW:
|
|
- or go back to the newest paste.
1 | typedef struct | |
2 | { | |
3 | float4 origin; | |
4 | float4 direction; | |
5 | } | |
6 | Ray; | |
7 | ||
8 | __kernel void primary( const int width, | |
9 | - | const int height, |
9 | + | const int height, |
10 | - | const float widthArg, |
10 | + | const float widthArg, |
11 | - | const float heightArg, |
11 | + | const float heightArg, |
12 | - | const float4 origin, |
12 | + | const float4 origin, |
13 | - | const float4 right, |
13 | + | const float4 right, |
14 | - | const float4 up, |
14 | + | const float4 up, |
15 | - | const float4 planePos, |
15 | + | const float4 planePos, |
16 | - | __global Ray* rays, |
16 | + | __global Ray* rays, |
17 | - | const int num) |
17 | + | const int num) |
18 | { | |
19 | const int idx = get_global_id(0); | |
20 | ||
21 | if(idx < num) | |
22 | { | |
23 | int2 coord = (int2)(idx % width, idx / width); | |
24 | ||
25 | float x = (float)(coord.x) - widthArg; | |
26 | float y = (float)(coord.y) - heightArg; | |
27 | ||
28 | rays[idx].origin = origin; | |
29 | rays[idx].direction = normalize(right * x + up * y + planePos); | |
30 | } | |
31 | } |