optifine icon indicating copy to clipboard operation
optifine copied to clipboard

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

Open SeaOfPixels opened this issue 2 years ago • 18 comments

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 avatar Jan 23 '23 02:01 SeaOfPixels

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 avatar Mar 21 '23 18:03 SeaOfPixels

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.

SeaOfPixels avatar Apr 04 '23 03:04 SeaOfPixels

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

UsernameGeri avatar May 24 '23 20:05 UsernameGeri

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.

SeaOfPixels avatar Jun 05 '23 13:06 SeaOfPixels

Old literal rotation method? Simulated? What?

UsernameGeri avatar Jun 05 '23 19:06 UsernameGeri

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.

SeaOfPixels avatar Jun 06 '23 03:06 SeaOfPixels

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).

UsernameGeri avatar Jun 06 '23 20:06 UsernameGeri

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

SeaOfPixels avatar Jun 07 '23 09:06 SeaOfPixels

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?

UsernameGeri avatar Jun 07 '23 09:06 UsernameGeri

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.

SeaOfPixels avatar Jun 08 '23 03:06 SeaOfPixels

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

roro1506HD avatar Jun 08 '23 05:06 roro1506HD

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

SeaOfPixels avatar Jun 08 '23 11:06 SeaOfPixels

I hope this gets fixed soon.

BlockyTheDev avatar Jun 27 '23 17:06 BlockyTheDev

@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

Jiingy avatar Jul 16 '23 21:07 Jiingy

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

UsernameGeri avatar Jul 17 '23 11:07 UsernameGeri

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

roro1506HD avatar Jul 17 '23 14:07 roro1506HD

Pinning this issue as a solution has been provided.

Jiingy avatar Jul 29 '23 04:07 Jiingy

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

Bhrol avatar Mar 06 '24 16:03 Bhrol