/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

Jump to content

Image of the Day

Day 17 -- a bunch more tools join the table :) #blender3d #screenshotsaturday #itssaturdaysomewhere #lowpoly #3D https://t.co/CYJucn0Lfv
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Math for computing relative sun direction

4: Adsense

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   

497
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?




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.