Jump to content
  • Advertisement
Sign in to follow this  
Alessandro Pozzer

DX11 Set Lighting according to Time of the day

This topic is 493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creating a simple Graphics Engine and I want to let the user set the time of the day for the scene, but I have problems translating it into the lighting direction. 

The light direction is now given by a vector of three float.

i.e. The user set time = 12 (noon). I want the light direction to be right on the top of the scene. 

Is there a way to achieve that? 

Thank you

Share this post


Link to post
Share on other sites
Advertisement

You can use longitude/latitude to describe the trajectory of the sun, and use the time to determine which point along the latitude that the sun is currently at. Longitude will control which direction the sun is actually coming from (east, north, west, south, etc). Latitude controls the height of the sun.

That would look something like this:

x = cos(long) * sin(lat);
y = sin(long) * sin(lat);
z = cos(lat);

If you want to simplify it, you can always assume a longitude of 0 and only focus on the latitude, which will only control the height of the sun.

Edited by Styves

Share this post


Link to post
Share on other sites
10 minutes ago, Styves said:

You can use longitude/latitude to describe the trajectory of the sun, and use the time to determine which point along the latitude that the sun is currently at. Longitude will control which direction the sun is actually coming from (east, north, west, south, etc). Latitude controls the height of the sun.

That would look something like this:


x = cos(long) * sin(lat);
y = sin(long) * sin(lat);
z = cos(lat);

If you want to simplify it, you can always assume a longitude of 0 and only focus on the latitude, which will only control the height of the sun.

Thank you for your reply! and how could I calculate longitude and latitude?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!