title: Motion Vector - how to calculate it properly?
body: <p>I'm trying to wrap my head around calculating motion vectors (also called velocity buffer). I found <a href="http://john-chapman-graphics.blogspot.com/2013/01/per-object-motion-blur.html" rel="nofollow noreferrer">this</a> tutorial, but I'm not satisfied with explanations of how motion vector are calculated. Here is the code:</p>
  <pre><code>vec2 a = (vPosition.xy / vPosition.w) * 0.5 + 0.5;
  vec2 b = (vPrevPosition.xy / vPrevPosition.w) * 0.5 + 0.5;
  oVelocity = a - b;
  </code></pre>
  <p>Why are we multiplying our position vectors by 0.5 and then adding 0.5? I'm guessing that we're trying to get from clip space to NDC, but why? I completly don't understand that.</p>