Practicing in shader optimization
Now, it is time to discuss how we can optimize our shaders. Alternatively, it is time to consider the other methods, such as optimizing built-in data types, which can significantly reduce the overhead of the Unity shaders' memory. We consider Unity shaders optimization for all supported platforms without any exclusions.
Very often, you will need to optimize shaders to achieve the same visual effect, but with a smaller number of textures for example. Primarily, when optimizing shader code, we would like to direct your attention to the types of variables. If you are willing to sacrifice the accuracy of calculations in order to decrease the quality to improve performance, then you should use the half
or fixed
variable types instead of float
. As an example, you can use a half
type of variable everywhere in your shader code:
inline half4 LightingCarVehicle (SurfaceOutput surface, half3 lightDirection, half3 viewDirection, half attenuation)
You can also replace...