Precompile/prewarm shaders to avoid jank

Hi,

is there a way to force RealityKit to compile/prewarm and cache all shaders that will be used within a Scene in advance – ideally in the background? This would be useful for adding complex models to the scene which sometimes can cause quite a couple dropped frames even on the newest devices (at least I assume the initial delay when displaying them is caused by the shader compilation) but also for CustomMaterials. Note this also happens with models that are loaded asynchronously.

Thanks!

Replies

Not directly, no. However, shaders should be cached across app launches, so you should only run into this slowdown once (until you reboot the device). Additionally, we are investigating ways to improve load times across the engine.

About CustomMaterial, we do a bit of compilation when you create the material, and a little more once you add it to a mesh. CustomMaterials are created synchronously, so you should probably generate your CustomMaterials during app launch/during a loading screen.