Jump to content

  • Log In with Google      Sign In   
  • Create Account


Math for computing relative sun direction


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
20 replies to this topic

#21 Meltac   Members   -  Reputation: 354

Like
0Likes
Like

Posted 08 November 2012 - 04:19 PM

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?

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS