Seriously: How to deal with Runtime-Downloaded Normal (not bump) maps without changing shaders?
Hi,
I am trying to download and apply normal maps (the blueish ones, not(!) bump maps) during runtime (in WebGL). In Editor, you can easily mark them as normal map and done. During runtime, you cannot since you cannot use TextureImporter.
I am using DownloadHandlerTexture.GetContent(unityWebRequest) to download a Texture (WWW shoes the same results). If I assign this map as normal map, obviously it looks fucked up:
I suppose there are two reasons for it:
1. Unfortunately, Unity seems to import it and applies gamma correction without being asked to and gives no option to turn that off.
2. The texture is not packed in Unity's own normal map packing format, so the unpackNormal function within the shaders return garbage.
I know you can change the shader to not use UnpackNormal(fixed4 packednormal), but I am using a large variety of shaders and also materials on AssetBundles with Normals that have been marked as normal maps during buildtime.
For gamma, I tried to reverse the wrong gamma correction by iterating over the image and Pow(value,2.2f), which seems to have made it a bit better. However, it does not solve the problem. I can't be the first one who just wants to use runtime downloaded normal maps in standard shader, right? It seems super simple.
I found solutions that changed shaders, ones that converted bump maps, but not a single one to this specific problem.