title: Calculating screen texture coordinates in CG/HLSL
body: <p>In OpenGL , sometimes when doing multi-pass rendering and post-processing I need to apply texels to the  primitive's assembly fragments which are part of full screen texture composition.That is usually the case when the current pass comes from FBO texture to which the screen quad had been rendered during previous pass.To achieve this I calculate objects UV coordinates  in SCREEN SPACE .In GLSL I calculate it like this:</p>
  
  <pre><code>     vec2 texelSize = 1.0 / vec2(textureSize(TEXTURE, 0));
   vec2 screenTexCoords = gl_FragCoord.xy * texelSize;
  </code></pre>
  
  <p>Now I am experimenting with Unity3D which uses <a href="http://en.wikipedia.org/wiki/Cg_%28programming_language%29" rel="nofollow">CG</a>/HLSL.The docs for these languages are poor.How can I calculate screen uv coordinates in CG/HLSL?</p>