Godot's runtime shader loading hiccups - how to solve?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

Hi. This has surely been discussed before and I am curious what your tactics are for dealing with this problem. In a 3D scene in Godot, unless the camera sees all shaders/materials used in a level at frame 1 and the engine has a chance to compile them at the start, there will be significant frame drops further on as you move through the level and new materials enter the viewport. What tips does everyone have for dealing with this? I heard some people build a ‘wall’ of all possible materials and pop it for a split second at the start for the camera to see them and compile. Seems like a hacky workaround…
Is there a recommended way to tackle this?

:bust_in_silhouette: Reply From: Calinou

See this tutorial: https://www.youtube.com/watch?v=Cg4ZT6X0ghs

Godot will support shader caching and threaded compilation in Godot 4.0 thanks to Vulkan, but OpenGL makes this very difficult (if not impossible).