GTcreyon / SM63Redux

Code base for Super Mario 63 Redux
https://sm63redux.com
Mozilla Public License 2.0
193 stars 26 forks source link

Game lags when selecting FLUDD for the first time #7

Open GTcreyon opened 1 year ago

GTcreyon commented 1 year ago

Describe the bug When selecting a FLUDD nozzle for the first time, a momentary lag spike occurs.

To Reproduce Open the game fresh, and either collect a FLUDD nozzle or use a command to unlock it and switch to it.

System Information

GTcreyon commented 11 months ago

Still happens in 4.1.

Koopa1018 commented 11 months ago

Seeing as this problem predates #93, my assumption that it was lag from sound loading may not hold true

Kuma-Boo commented 11 months ago

This sounds like a shader compilation issue to me. It seems to be a pretty common thing in godot projects.

The most common workaround seems to be to load a special scene when the game first starts and have all the effects appear on screen for at least a single frame to force the shaders to initialize.

Godot 3.5 also added async shader compilation, although it's unfortunately 3.x/3d only.

Koopa1018 commented 11 months ago

Shader compilation would make sense.... The water meter uses both a clipping mask (BubbleMask) and a Light2D (PowerMask), either of which could easily need a new shader compiled.

The title screen logo also uses a Light2D...which means that shader should already be in memory by the time the game starts. But it could be that the two lights are different in some way that prevents reuse of the first one.... As far as I can tell, Logo/ShineMask is exactly the same as WaterMeter/PowerMask, except for the Layer Min/Max, Item Cull Mask, and of course Texture. Apart from Texture, I could see any of those differences leading to a light shader recompile, but that depends on how the Godot shading pipeline works (and doesn't quite jive with their style)....

But before we test any of this, I'm gonna try nuking the shader cache to make sure we're even on the right track.