title: camera in ray tracing
body: <p>I’ve completely stuck with camera in ray tracing. Please, take a look at my calculations and point me out where is the error. I’m using left handed coordinate system.</p>
  
  <p>x,y // range [0..S) x [0..S) //pixels coordinates</p>
  
  <p>Now, let’s transform pixels coordinates to parametric coordinates of camera plane:</p>
  
  <pre><code>xp = x/S * 2 – 1; 
  yp = y/S * 2 – 1;
  </code></pre>
  
  <p>xp, yp // range [-1..1] x [-1..1]</p>
  
  <p>calculation of camera basis:</p>
  
  <pre><code>//eye - camera position
  //up - camera up vector
  //look_at - camera target point
  
  vec3 w = normalize(look_at-eye);
  vec3 u = cross(up,w);
  vec3 v = cross(w,u);
  </code></pre>
  
  <p>so ray direction should have following coordinates:</p>
  
  <pre><code>vec3 dir = look_at – eye + xp*u + yp*v;
  ray3 ray = {eye, normalize(dir)};
  </code></pre>