Godot Version
v4.3.stable.official [77dcf97d8]
Question
I have a character that is doing a wall slide and I want a particle system to emit smoke while this is happening. I created a GPUParticles2D exiting smoke puffs and it works fairly well. I’m turning it off and on by setting it’s emitting
flag to true when the wall slide is happening.
emitting
is initially set to false when my level starts. The first time I set emitting
to true, the game hangs for about 2 seconds. After the initial hang, I can turn emitting
on and off and it responds right away. Since this hang happens when the user starts their first wall slide, it’s pretty noticeable.
It is using a flip book animation, but the texture is pretty small and only 6 frames long.
I suspect the shaders are being compiled on the fly when the emitted
flag is set. Is there something I can do to ‘preload’ the particle system or make it responsive the first time I set emitting
to true?
Im pretty sure it doesnt hang like that when you do a build of the game. I think its an editor thing
Not sure if this is related.
In a recent blog post Godot Rendering Priorities: September 2024 – Godot Engine they mention:
This work was finished during the 4.3 dev cycle, but we deferred merging it to 4.4 because of its size and complexity. As a reminder, this PR implements the concept of an “ubershader” which is basically a version of the shader that contains all features and is compiled at load time. We pair the ubershader with the ability to compile specialized shader pipelines in the background. This way when we draw a new object, instead of freezing and waiting for the pipeline to compile, we fallback on the ubershader and compile the specialized shader in the background.
This is happening when I run from the editor - do you mean I need to export first?
GPUParticles2D has a ParticleProcessMaterial which handles moving the particles in addition to the CanvasItemMaterial which draws the sprites. I’m not sure if either of these use the ubershader.
Yes. I belive you wont have that issue when you have a build of yor game. Its just when its ran in godot editor. Make a biuld of your game and try it out
I exported for Windows, but I’m getting the hang when I run that too.
Sorry, my only suggestion is to make it emit as soon as the level loads. So the player wont notice it on the first wall slide.