afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
988 stars 68 forks source link

Sun trajectory doesn't match original game #142

Closed Allofich closed 3 years ago

Allofich commented 5 years ago

Right now the sun in OpenTESArena moves straight up and down when rising or setting. As you probably know, it moves diagonally in the original game.

sunrise Sunrise (6:18 AM - 8:10 AM)

sunset Sunset (4:25 PM-5:21 PM)

In the original game, the sun basically moves once every 3 game minutes, although sometimes the interval from the last movement is only 2 minutes. Movement generally seems to be a in a repeating pattern of: diagonal, straight, straight.

early sunrise Sunrise (6:02 AM-6:17 AM)

As an aside, the movement at the very beginning of the sunrise seems like it might follow a slightly different pattern. It was hidden by a cloud in the above recording, and I recorded it again, but it's hard to tell from just this...

The late sunset was also hidden by a cloud so I didn't get a recording of it.

Anyway, I hope this information is useful for you.

afritz1 commented 5 years ago

Oooh, gifs. Gifs are nice. @Carmina16 and I are working through stuff like this right now with star rendering. The sun's direction probably needs to be a function of the player's current latitude.

Allofich commented 5 years ago

The sun's direction probably needs to be a function of the player's current latitude.

Is the original game that advanced in its model? I took these in the wilderness cell just outside the city gates of Glenpoint, High Rock.

afritz1 commented 5 years ago

Follow along in our conversation here: https://github.com/afritz1/OpenTESArena/commit/d9e5498769972c3c307e6569a76dafc5aa974883#commitcomment-32514730

Allofich commented 5 years ago

Looks like a good bit of math going on here, more than probably anyone would expect! Looks pretty complicated but I'll try and take a closer look at that conversation later, thanks. Hopefully those .gifs can be useful for something, even if just as a guide for what the movement should generally look like. It was fun to make them, anyway.

afritz1 commented 5 years ago

On a related topic, I need to confirm whether space objects appear when it's cloudy/rainy/snowy. @Allofich would you be interested in checking that out?

Carmina16 commented 5 years ago

Sun, stars, and moons are not drawn if there is fog or any weather effect.

afritz1 commented 5 years ago

Cool, I can implement that soon then, thanks.

afritz1 commented 5 years ago

The sun's trajectory is now a function of latitude in commit 3b20adec56259ee2ae4f3d44f775d9ff08896898. It doesn't look the exact same as the gifs above, but maybe that's okay? I dunno.

Allofich commented 5 years ago

Just tried out the latest code, and it's really starting to look good! With the fast timescale that's being used currently, looking up at the rotating stars in the night sky it felt I was in a planetarium, or on a really quickly rotating planet.

I traveled to Glenpoint, High Rock and watched the sun movement to compare it to what I saw in the original game, and it looked fine except that it was reversed. It was moving to the left rather than the right.

afritz1 commented 5 years ago

It looks even cooler when you change the star count from 40 to 8000 in DistantSky::init() 😉. That's what I used to make sure the projection was correct at every point in space. Like I said on Twitter a while ago, distant land and stars are what give the game its "wonder" and make you feel like you're a part of something bigger.

So yeah, I tested it in Glenpoint as well, but in order to have it rotate to the right, it seems like the sun's latitude needs to be changed far more than what @Carmina16 suggested (with the additional 13 Arena angle units). So I'm not sure of the correct way to go about it. And besides, whenever the player's in the southern hemisphere, the sun barely makes it halfway up in the sky, so we can't just "add more" to the sun's latitude.

Carmina16 commented 5 years ago

Make sure you are rotating it -(latitude+13) counterclockwise (or latitude+13 clockwise).

afritz1 commented 5 years ago

This commit 002b47bfeb413f5b879dc98cb4fe0e50d6c942ab makes the sun's trajectory look a bit better. It goes up and slightly to the right in Glenpoint and up and slightly to the left in Archen Grangrove, Summurset Isle. There is a mountain in the way at Archen Grangrove but I could see where the sun was going after ~7:00am I think.

I think part of the problem was that the effect of latitude on the rotation was too strong. I changed it from Pi/2 to Pi/8 and it looks a lot better. Still not perfect though? Not sure.

Edit: slightly modified per @Carmina16's comment: 83381ba1d4544e1529eb8c4d38aae3dee7c50788

Carmina16 commented 5 years ago

The maximum vanilla sun angle should be about 60°. What values do you get?

afritz1 commented 5 years ago

About 20 degrees in Solitude, Skyrim I guess. But if it looks correct, then what? If I don't use Pi/8 in the latitude calculation then the sun appears too close to the horizon at noon in more south places like Summurset Isle and Black Marsh.

Maybe the angle you're talking about is the complement of the angle I'm using? Maybe I'm only 10 degrees off then, which would be the reason why it almost looks correct.

afritz1 commented 3 years ago

Recently made some revisions to the sun and moon positions on the chunk system branch (#200). Still not sure if they match the original game but the way the positions are defined now is a lot more convenient.

Thunderforge commented 3 years ago

@Carmina16 If you get a chance, it would be helpful to see if the positions are any closer to the original game now in the newly released 0.13.0.

Thunderforge commented 3 years ago

From @afritz1 in Discord:

The three places I would test with are the Imperial City, Solitude in Skyrim, and Senchal in Elsweyr. The sun is affected by the player's latitude, and those three places have the most distinct latitudes (Imperial City: middle, Solitude: max, Senchal: min).

Thunderforge commented 3 years ago

In the Discord, Zeri proved that the 0.14.0 behavior is working as intended, as shown in the two videos attached.

https://user-images.githubusercontent.com/6200170/123186291-7088e980-d45d-11eb-8cee-59ae3422e348.mp4

https://user-images.githubusercontent.com/6200170/123186295-71ba1680-d45d-11eb-8d09-ebc2efaa3fec.mp4

Closing this bug as complete.