I’m trying to load normal maps from files at runtime, using Texture2D.LoadImage, but when my project is set to linear color space, they come in distorted, due to the textures being converted to linear from sRGB.
Is there any way to turn this off? Right now I just set my project back to sRGB as a temporary fix, but things don’t look as nice now.
I tried doing Mathf.pow(color, 2.2f) afterwards, but the results, while kinda close, aren’t quite there.
First, and most importantly, when creating the texture initially, it needs to be set to linear, using a constructor override, like so:
Texture2D normal = new Texture2D(2, 2, TextureFormat.ARGB32, true, true);
(The 2x2 texture size is because it will get re-sized anyway after loading the texture)
This will disable any gamma operations on the texture when loading.
The second thing I found out is that Unity assumes 2.0 gamma, not 2.2.