I’m currently working on a project that displays two objects, one at a time. When all assets load, Object1 is rendered, and Object2 has visibility set to false. Upon user interaction, their visibility is swapped, so Object1 is not visible, and Object2 is visible, and so on.
My problem is that the shaders for Object2 don’t compile and don’t get passed to the GPU until JUST BEFORE being rendered for the first time, causing a visible “hiccup” in performance. I would much rather this to happen only once, at the beginning of the whole experience, and not in the middle while swapping objects.
Before Object2 is first rendered:
After Object2 is first rendered, takes a second to create the new shaders in the GPU:
Is there a way to get all shaders, textures, buffers to the GPU before they’re first rendered? I’ve found a trick is to render objects at a small scale for one frame, or at very low opacity, but it’s a pain to do this for all objects that will be visible in the future. Is there a way to pre-compile, or to tell the engine to prepare the shaders to be ready for action in the future?