in metal shader implementation, it is recommended to use half4 instead of float4. but how to know if we can use half4 instead of float4? how to know the amount of precision we need ?
You know you can use half4
, instead of float4
, depending on how the colour is encoded as it's passed into the fragment shader.
Half-precision floats can represent the values 0 to 2048 exactly so if it's used to represent an 8-bit channel (i.e. pretty much all commonly-used texture formats) then there is no loss of fidelity.
It will also save memory transfer bandwidth, which is important on mobile platforms.