- Home /
Changing shader at runtime vs multi-purpose shader
I've been doing a course on shaders and I'm thinking of creating a death animation shader which puffs up the mesh and then explodes.
My question is: Is it better to do this using 1 shader on the model which handles everything. Or switching from 1 shader to my "Explode" shader just before the enemy dies?
I'm thinking that since the fatness parameter will be calculated every frame by the shader, it might hinder performance by having it applied to all enemies at all times.
Thanks in advance!
Answer by JVene · Aug 28, 2018 at 06:37 AM
Generally, this depends on the platform. This is related to the question of the "Uber shader" (Google provides). On mobile devices, where the GPU is weaker, it is generally found that the demand of a larger shader is worse than switching shader programs. Conversely, on consoles and PC platforms, the switch of the shader program is relatively more costly than complex shaders. So, it depends on your primary target device type.
Your answer
Follow this Question
Related Questions
Performance Issue On Certain Devices 0 Answers
Too many shaders cost 0 Answers
Low Poly Alpha Cutout vs Full Models Performance 1 Answer
Optimizing Performance with tris 0 Answers
URP Post Processing Volume Mobile Bloom 30 FPS LOCK 0 Answers