- Home /
Check performance of shader for mobile
If I use specular shader for mobile device then I got following message on inspector. Whether I have to use specular effect for mobile device or not? But I want to use this shader. I want your suggestion in this. Whether it consumes more resources?
Answer by DaDonik · Jun 27, 2015 at 08:51 AM
That shader will certainly run poor on mobile. Make sure to use the specular shader for mobile, which is optimized for ... mobile :D
Let me try to explain that whole shader thing:
Those shaders are pixel shaders. That means they are basically a small program that is run on each pixel. The more complex a shader is, the longer the program for each pixel gets and the more time it needs to render it to the screen. That also means that the screen resolution is a large factor, since the shaders are run for each pixel.
As you most likely know, PC's have much more graphics power than mobile devices, so you really should use the shaders that are optimized for mobile.
@DaDonik, Thanks for help and awesome explanation. I have one question, how to decide shader is vertex or fragment shader?
The fragment/pixel shader will run on each pixel as i said above. This is the better looking but slower version.
The vertex shader works on the actual mesh of your 3D object. It's much faster but you can't expect much from it. You can't have nice specular on your mesh if only the vertices are used for the calculations. All it can do is interpolate the look of the surface of each polygon depending on it's vertices. That means you will have problems getting a sphere to look round if you don't use many polygons, which is not really good for mobile.
Note that vertex shaders in general can also move vertices in your mesh, but those shaders on Unity's materials are purely for visuals and do not affect the mesh. So these vertex shaders can be considered the old way to show a 3D object on the screen, while fragment/pixel shaders are the new way.
Hope that helps =)
@DaDonik, Thanks for all of above. One more thing, If I want to use reflective shader then in mobile section we don't have that shader then how to get same effect for mobile?
Reflection is a really(!) expensive thing to do. Thats why Unity doesn't have a mobile version for it. I'm afraid you have to wait a few years until mobile devices can handle that without problems.
You can try to use the non-mobile version, but it's not guaranteed to work on every device and it will most likely be slow as hell if it works at all.
@ siddharth3322 U can use reflective and non mobile shaders but selectively and for most important objects/elements, it will have less impact than using them for all the objects in the scene. You can check unity docs, what they had mentioned is "use mobile shaders wherever u can". In now a days we are seeing more powerful mobile devices which can handle them without any problems.