Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Meltac

Member Since 29 Mar 2012
Offline Last Active Apr 19 2013 08:08 AM
-----

#4947458 Math for computing relative sun direction

Posted by Meltac on 08 June 2012 - 01:38 PM

Sure, I'm so free to quote some other guy who has made some screenshots:

Notice how the telephone pole is blocking the sun where I am standing, which logically means I should be standing in its shadow. But notice where the pole's shadow is. Way in front of me! Nowhere near where I am:

http://i19.photobuck...unoutofsync.jpg

Here's the sun behind a tree, blocking the sunlight from my view, so I should be in its shadow, but again, the shadow is way in front of me:

http://i19.photobuck...noutofsync2.jpg

And a graphic to show what's happening:

http://i19.photobuck...67/shadows2.jpg

EDIT:
I know from other source that the reason for this lies in the way the engine calculates the sun's coordinates which are passed to the shader. The geometrical horizonal taken for sun light direction calculation is about 40 degrees below the game world's horizon - meaning I'll need a way to correct this shader-wise. A simple vector shift or rotation with these 40 degrees should be accurate enough to make shadows look acceptable.


PARTNERS