Mobile Shader error optimization?

Hi all.

For unity, make the Shader of the sky, great features in one Shader.

And I noticed a theme, if just the sky with paint = 59 fps
If added on top and the clouds (just one 1K texture) the fps drops to 50. Don't know why, maybe because a lot of primitive checks if else ?

What's wrong?
March 23rd 20 at 19:22
2 answers
March 23rd 20 at 19:24
Solution
Will add to the answer @Jailyn.Mayert

if-else in the Shader, in most cases (depends on specific Graphics API and hardware), is creating additional branches with the calculations at the level of Shader compilation. Let's say you have two textures and you validates using if-else ' what to display, and then check using if-else as it is for example to transform or to repaint. As a result, the Shader calculates all FOUR versions of the texture, and after it displays only one of them. Spice with another if-else, and the miscalculation has EIGHT versions of the texture. That is, in the Shader if-else statement "cuts" are not necessary part of calculations as in the script, and believes it, just shows only what has passed through all the checks.
Yes, all true, I tested, just blocks IF ELSE empty robbed by 10-15 fps.

I don't know why so stupid, why in all languages works fine. - leif.Schmitt22 commented on March 23rd 20 at 19:27
@leif.Schmitt22, This is due to the GPU architecture and parallel computation - conventionally, the processor of 1000 cores but with limited functionality. Complex operations of the kernel are not able to do, but simple do 1000 times faster (at the expense of quantity). It is necessary to understand and consider when creating shaders. - chelse commented on March 23rd 20 at 19:30
March 23rd 20 at 19:26
if-else Shader - bad, Yes.
But the reasons for the fall can be very different - should at least watch the code of the Shader. Well popratiloff worth it.

Find more questions by tags Unity Game EngineC#