We are going to build a simple DiffuseShader to take a look at a few ways in which you can optimize your shaders in general.
First, we'll optimize our variable types so that they use less memory when they are
processing data:
- Let's begin with the struct Input in our shader. Currently, our UVs are being stored in a variable of the float2 type.
- Remember that floats provide the highest form of precision at a full 32 bits of memory. This is needed for complex trigonometry or exponents, but if you can handle less precision, it's much better to use either a half or a fixed instead. The half type provides up to 3 digits of precision using half the size, or 16 bits of memory. That means we can have a half2 with the same amount ...