Could some one help me to understand this code and explain it?
It's about converting from 3D space to 2D position, so that I can use it in another Effects (.fx) files, but I am a bit confused.
float viewportWidth;
float viewportHight;
// calculate the 2D screen Position of a 3D position
float2 postProjectionToScreen(float4 position)
{
float2 screenPos = position.xy/position.w;
return 0.5f *(float2(screenPos.x,-screenPos.y)+1);
}
// Calculate the size of one half of a pixel , to convert
// between texels and pixels
float2 halfPixel()
{
return 0.5f/float2(viewportWidth,viewportHight);
}
