+8
Under review

performance cost indicator

Dennis V H 9 years ago updated 9 years ago 4
It would be great if there is an indicator or score at each node, like back in the days with strumpy shader toy, for its performance cost. And an overall indicator which is just a sum of those. This should help out optimizing shaders better.
+3
Honestly, any kind of performance metric would be fantastic. Right now, I'm not sure where I can optimize most of my shaders.
Under review
Unfortunately, the instruction count isn't exposed in a nice way in Unity.
I can extract it from the compiled shaders, but if Unity ever change the output of it, I have to rewrite the parser for it.

I've talked to Unity about it as well, but they don't seem to want to expose it in a neat way, saying that the instruction count isn't very accurate in measuring performance (which is partially true) anyway.

In the meantime:
  • If / Step can be expensive, especially on mobile
  • It's expensive to use a texture to calculate the UV coordinates for a second texture, especially on mobile
  • Trigonometry is a bit expensive
  • RGB to HSV is a bit expensive

+2
Maybe it would be a good addition to highlight some expensive / incompatible nodes when a mobile platform is selected saying: "Don't do this, it may kill your shader's performance"
An experienced user should be able to use them anyway, but it would help especially if there is no time for in-depth-optimization.

Maybe add just a made up cost indicator like multiply is 1, texture lookup is 2, if/step is 5, etc and the score is represented by color or a small indicator. And at the last output node there's an indicator with just the sum of those numbers. We can all figure out ourselves what it means for the hardware we run on, it's just an indication how to optimize. We don't need an exact instruction count as it will always be relative and differ by unity implementation, different platforms and future hardware.