Modifying our shaders for mobile
Now that we have looked at a broad set of techniques for making optimized shaders, let's take a look at writing a nice, high-quality shader targeted at a mobile device. It is 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 approxview
or halfasview Lighting
function variables. We can also reduce the number of textures we need and even apply better compression to the textures we are using. By the end of this recipe, we will have a nicely optimized, normally mapped Specular Shader that we can use in our mobile games.
Getting ready
Before we begin, let's create a fresh new scene and fill it with some objects that we will apply to our MobileShader
:
- Create a new scene and fill it with a default sphere and a single directional light.
- Create a new material (
MobileMat
) and shader (MobileShader
), and assign the shader to the material...