[Unity Shaders] Mobile Shader Adjustment-customizes the Shader and shadersadjustment for Mobile phones.
This series mainly references the book "Unity Shaders and Effects Cookbook" (thanks to the author of the original book) and adds a bit of personal understanding or expansion.
Here are all the illustrations in this book. Here is the code and resources required for this book (you can also download them from the official website ).
========================================================== ===================================================== =====
Preface
In the previous article, we learned some tips to optimize the Shader. This time, we will learn more techniques to implement a more complex Shader: Normal-Mapped Specular Shader. These techniques include: using two new variables halfasview or approxview of the illumination function, reducing the number of textures used and better compressing textures.
Preparations
- Create a new scene and a sphere, and add a parallel light.
- Create a new Shader and Material, which can be named MobileShader.
- Assign Shader to Material and assign Material to sphere.
Implementation
Finally, the result is as follows:
Explanation
Finally, we will summarize all the technologies we have used: optimizing variable types, sharing UV coordinates, reducing the number of processed light sources, allowing the Shader to work only on a specific Renderer, and replacing the exact value with an approximate value, and reduce or compress textures.