typedef struct { float4 origin; float4 direction; } Ray; __kernel void primary( const int width, const int height, const float widthArg, const float heightArg, const float4 origin, const float4 right, const float4 up, const float4 planePos, __global Ray* rays, const int num) { const int idx = get_global_id(0); if(idx < num) { int2 coord = (int2)(idx % width, idx / width); float x = (float)(coord.x) - widthArg; float y = (float)(coord.y) - heightArg; rays[idx].origin = origin; rays[idx].direction = normalize(right * x + up * y + planePos); } }