Editing Environment
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 166: | Line 166: | ||
The following is a simplified explanation of the procedure by which the game determines the light intensity supplied by the sun at a given latitude, day of the year, and time of day. | The following is a simplified explanation of the procedure by which the game determines the light intensity supplied by the sun at a given latitude, day of the year, and time of day. | ||
− | + | First, the latitude normal vector <code>N</code> can be calculated as the vector <code>{cos(''latitude''), sin(''latitude''), 0}</code>. Note that this is always orthogonal to the Z-axis (the Y-axis passes through the planet's poles, not the Z-axis) with a positive X-value. For example, the latitude normal vector at the equator would be <code>{1, 0, 0}</code> while at 45° N it would be <code>{0.707, 0.707, 0}</code> | |
− | + | ||
− | + | To calculate the sun position vector <code>P</code>, [[wikipedia:Unit vector|normalize]] the vector <code>{cos((''day_percent'' - 0.5) × 360°), -cos(''day_of_year''/60 × 360°) × latitude_fraction(''latitude''), sin((''day_percent'' - 0.5) × 360°)}</code> then rotate it an amount towards latitude normal vector <code>N</code> based on the graph on the right, but not passing it (if applicable). The function <code>latitude_fraction(''latitude'')</code> equals <code>0.2</code> below latitude <code>70</code>, <code>1.5</code> above latitude <code>75</code>, and is linearly interpolated between. | |
− | + | ||
− | + | Using latitude normal vector <code>N</code> and sun position vector <code>P</code> (both should have magnitude <code>1.0</code>), the daylight intensity is based on the [[wikipedia:Dot product|dot product]] of the two, with <code>0.0</code> to <code>0.7</code> linearly corresponding with 0% to 100% light intensity and <code>0.7</code> to <code>1.0</code> being clamped at 100% light intensity. | |
− | |||
− | |||
Interestingly, while some effects are applied differently above latitude <code>70</code> (70° N), these do not seem to apply below <code>-70</code> (70° S). | Interestingly, while some effects are applied differently above latitude <code>70</code> (70° N), these do not seem to apply below <code>-70</code> (70° S). |