How to avoid initial Particle spawn Hitch?

We’ve noticed the first time particle systems are dynamically spawned in the world there is a performance hitch. eg Impact effects, muzzles flashes, explosions, etc. How to preload them or avoid this in another way? The textures referenced by their material do appear to be referenced. The assets themselves are just a UParticleSystem* UPROPERTY.

1 Like

I would also like an answer to this extremely annoying problem.

Often, first spawn hitches are caused by the engine having to load content. This doc talks about how to load your game’s assets asynchronously

According to my profiling, the initial particle hitches are not caused by having to load content, but by having to re-link the OpenGL shaders after changing parameters and/or using them in a new combination. (LinkProgram in OpenGLShaders.cpp)

To alleviate that, FOpenGLProgramBinaryCache was introduced in UE4.13, which can be enabled with r.UseProgramBinaryCache=1

In addition to the linking, you might also see hitches due to shader compilation. To circumvent that, you need to cache your shaders:

Also, you can minimize the problem by using fewer unique shaders. For example, if you want to have the same effect in multiple colors, then instead of copy&pasting the particle system, you can use Instance Parameters. That way, all color variations use the same shader, but with different color values. As a result, you only need to link once for all colors, as opposed to compiling linking each color variation separately.

EDIT: After trying to fix this for myself for a while, I’d say that this is still (4.17.2) quite broken. The shader cache would be the correct solution (apart from the annoying procedure to generate it), but it currently crashes on ES2 and is thus useless. The bug Unreal Engine Issues and Bug Tracker (UE-47553) will hopefully be fixed in 4.18. Until then, we’re stuck with so-so workarounds.

I also want to know if there is any easy solution to this problem