Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2013  |  syntax: C  |  size: 0.62 KB  |  hits: 201  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }