It does, because the ViewProj matrix needs homogeneous coordinates for it to work correctly. The resulting vector will have a w-component that is essential for the projection to work.
Thanks. You're right, it does - it places my sun always in the exact center of the screen, regardless of the camera/view direction!
So that code still doesn't seem right. Also, in the version that more-or-less works (besides the inaccurate sun positioning), I didn't do the
[source lang="cpp"]// Transform sun position to screen spaceSunPos = mul( SunPos, ViewProj );[/source]
at the beginning of the code. I remember that I had assumed that the sun position that I'm getting is already transformed. However I never was sure about that.
I may be misunderstanding the whole thing, so that I'm not able at all to figure out what the problem might be. Could you please explain your code a bit? E.g. why do I have to transform into screen space first, and then apply another transformation? What is that TexAdj matrix, where do those values come from, and why do it need it?