sp614x / optifine

1.81k stars 416 forks source link

[1.19.3 to Latest] Custom sky rotation has a visual "bobbing" effect due to JOML calculation #7235

Open SeaOfPixels opened 1 year ago

SeaOfPixels commented 1 year ago

NOTE: Cause of this detailed in this reply.

Description of Issue

1.19.4 uses the old 1.12 custom sky rotation system, where the sky rotates completely to the right, rather than the new custom sky rotation system in 1.19.2, where rotation is simulated by shifting back and forth. This causes any resource packs that use higher rotation speeds for the 1.19.2 system to have hyperspeed skies in 1.19.4 due to it using the old rotation system. (Attachment 1)

Additionally, the skybox moves along with the view bobbing when rotating fast. (Attachment 2)

For clarification, this is my resource pack New Default+. In 1.19.2, the sky does not do this. These are the properties for my daytime sky.

startFadeIn=5:30 endFadeIn=6:00 startFadeOut=17:50 endFadeOut=18:40 blend=screen rotate=true speed=5.0 axis=0.0 -0.2 0.0 source=./day.png weather=clear

To further clarify why it doesn't do this in 1.19.2: in 1.19.2, OptiFine's sky rotation goes back and forth to simulate a moving sky without literally rotating, while in 1.12 (and now 1.19.4), the sky completely rotates to the right in circles. The "speed=5.0" is a good speed for the former "back and forth" 'simulated' skybox rotation in 1.19.2, while "speed=1.0" is suited for the 'literal' skybox rotation in 1.12/1.19.4. I suspect/hope the reverted skybox rotation in 1.19.4 is a mistake, and this is what this bug report is focusing on.

OptiFine Version

1.19.3 I3, 1.19.4 l4, 1.20-pre4_HD_U_I5_pre1, OptiFine 1.20_HD_U_I5_pre3

https://user-images.githubusercontent.com/62183036/213954787-39a3a7f4-5d4c-4c53-8c1d-300be91f1c38.mp4

https://user-images.githubusercontent.com/62183036/213955243-2ebff912-74bd-4ed1-8b04-6765f3ddcdd8.mp4

SeaOfPixels commented 1 year ago

Hoping for a fix soon, this is the last major bug effecting resource packs (other than [https://github.com/sp614x/optifine/issues/7234] but that's more minor).

SeaOfPixels commented 1 year ago

In the latest release of my pack I set the speeds to 1.0 as a temporary fix for this bug, but the sky still speeds up towards the end of the night causing the view bobbing glitch, and I don't understand why. It doesn't do this in 1.12 even though I thought they used the same rotation method. Rly frustrating to not be able to fix this on my end.

UsernameGeri commented 1 year ago

You have the axis specified incorrectly. Write axis=0.0 -1.0 0.0 and it will solve the issue.

SeaOfPixels commented 1 year ago

This fixes the speeding up and slowing down, but it doesn't fix the sky still using the old literal rotation method rather than simulated.

UsernameGeri commented 1 year ago

Old literal rotation method? Simulated? What?

SeaOfPixels commented 1 year ago

I explained it in the post above, the way the sky rotates changed between OptiFine 1.19.2 and OptiFine 1.19.3, even with your axis fix. The rotation method is now back to what was used all the way back in 1.12 now.

UsernameGeri commented 1 year ago

I tested 1.12.2, 1.19.2-3- and 4 and it all works the exact same way. Can you show an example where the sky behaves differently between these version? Also I still have no idea what you mean by "simulated" and "back and forth". I think you're a bit confused about this, I don't think the sky rotation has ever been changed since its integration from mcpatcher to optifine (it's not in the change logs anyway).

SeaOfPixels commented 1 year ago

Here is a comparison:

1.19.2, sky simulates the feeling of rotation by swiveling back and forth: https://github.com/sp614x/optifine/assets/62183036/0deef3b0-0c5b-44cf-93fa-e05084798615

1.19.3/1.19.4/1.20, sky literally rotates in a circle: https://github.com/sp614x/optifine/assets/62183036/37d1b4fc-e8eb-415e-8add-ef61ef99e435

UsernameGeri commented 1 year ago

How does this swivelling look in real time? I've never seen such behavior before. Can you also share the properties file for this sky? Also what specific optifine version are you using?

SeaOfPixels commented 1 year ago

They're the properties in the original post. Also this is the best I can show it within the constraints of video file size, I assure you it swivels like this without adding time.

roro1506HD commented 1 year ago

After looking more closely to the source code of <1.19.2 OptiFine and 1.19.3+, there is nothing that changed regarding all that. What I looked and tested though, is that 1.19.3 was when JOML has been introduced in the code, and this is what is causing all this.

I tested by bringing back some old Mojang's math library classes, tweaked them a bit to fix issues and I can affirm that the JOML calculation is what is causing all that mess. The old math library and the new are definitely not doing the same calculations.

I took out the necessary math to compute the rotation and put it all in a method, to save some time to sp614x if he wants to use it: https://pastebin.com/pSWqZVh7 This method can be used in replacement of PoseStack#rotateDeg: Current:

matrixStackIn.rotateDeg(360.0F * (angleDayStart + celestialAngle * this.speed), this.axis[0], this.axis[1], this.axis[2]);

Replacement:

this.replicateOldMulPoseBehavior(
    matrixStackIn,
    (float) Math.toRadians(360.0F * (angleDayStart + celestialAngle * this.speed)), // The main difference is this being radians instead of degrees
    this.axis[0], 
    this.axis[1], 
    this.axis[2]
);

TL;DR

A math thing has changed in 1.19.3 that is causing all this, despite OptiFine not changing anything

SeaOfPixels commented 1 year ago

Hoping OptiFine is able to account for and fix this on their end, thank you for looking into this.

BlockyTheDev commented 1 year ago

I hope this gets fixed soon.

Jiingy commented 1 year ago

@sp614x Considering how prominent it is for resource pack users, it may be good to fix soon. A bug tester has provided an example of how to fix the issue here.

After looking more closely to the source code of <1.19.2 OptiFine and 1.19.3+, there is nothing that changed regarding all that. What I looked and tested though, is that 1.19.3 was when JOML has been introduced in the code, and this is what is causing all this.

I tested by bringing back some old Mojang's math library classes, tweaked them a bit to fix issues and I can affirm that the JOML calculation is what is causing all that mess. The old math library and the new are definitely not doing the same calculations.

I took out the necessary math to compute the rotation and put it all in a method, to save some time to sp614x if he wants to use it: https://pastebin.com/pSWqZVh7 This method can be used in replacement of PoseStack#rotateDeg: Current:

matrixStackIn.rotateDeg(360.0F * (angleDayStart + celestialAngle * this.speed), this.axis[0], this.axis[1], this.axis[2]);

Replacement:

this.replicateOldMulPoseBehavior(
    matrixStackIn,
    (float) Math.toRadians(360.0F * (angleDayStart + celestialAngle * this.speed)), // The main difference is this being radians instead of degrees
    this.axis[0], 
    this.axis[1], 
    this.axis[2]
);

TL;DR

A math thing has changed in 1.19.3 that is causing all this, despite OptiFine not changing anything

UsernameGeri commented 1 year ago

I wonder how reliable this fix would be. People will continue to use incorrect axes, would this fix account for that?

roro1506HD commented 1 year ago

This fix brings back the old behavior, making old skies work again

Jiingy commented 1 year ago

Pinning this issue as a solution has been provided.

Bhrol commented 8 months ago

Is the problem still active ? I'm experiencing the same type of bug right now