Now that we have seen quite a broad set of techniques to make really optimized shaders, let's take a look at writing a nice, high-quality shader targeted for a mobile device. It is actually quite easy to make a few adjustments to the shaders we have written so that they run faster on a mobile device. This includes elements such as using the
halfasview lighting function variables. We can also reduce the amount of textures we need and even apply better compression for the textures we are using. By the end of this recipe, we will have a nicely optimized normal-mapped, Specular shader for use in our mobile games.
Before we begin, let's get a fresh new scene and fill it with some objects to apply our Mobile shader:
Create a new scene and fill it with a default sphere and single directional light.
Create a new material and shader, and assign the shader to the material.
Finally, assign the material to our sphere object in our scene.