Advertisement
Guest User

Untitled

a guest
Apr 30th, 2013
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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,
  10.             const float widthArg,
  11.             const float heightArg,
  12.             const float4 origin,
  13.             const float4 right,
  14.             const float4 up,
  15.             const float4 planePos,
  16.             __global Ray* rays,
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement