I've been writing a custom packed surface shader that uses the alpha channel of a normal texture for additional shader functions. Because of this, I need to keep my normal textures set as 'Texture' instead of 'Normal' in the Unity import settings. Everything in the shader works perfectly fine, however Unity is constantly flooding me with Texture import warnings such as this: Code (CSharp): A Material is using the texture as a normal map. The texture must be marked as a normal map in the import settings. This is extremely annoying, because I am doing the exact opposite on purpose, yet I can't find anyway of removing this warning. I've edited the texture input properties in my shader so that it doesn't mention "normal" or "bump" or anything that would flag the texture as being a normal map... Code (CSharp): _NTex ("(RGB) Normal, (A) Height", 2D) = "(RGBA: 0.5,0.5,1.0,0.0)"{} And when the texture is decoded, it isn't referencing the texture directly either, but rather first processing it in a separate half3 struct... Code (CSharp): fixed4 texNorm = tex2D (_NTex, UVs); half3 norm = lerp( half3(0.5,0.5,1.0), half3(texNorm.r, texNorm.g, texNorm.b), _NormalStrength); o.Normal = norm * 2 - 1; No matter what I label the texture in my shader code I still am getting griefed with this error message. I've also tried deleting my project library in order to force Unity to recompile the shader references but this is still happening regardless. Does anyone have any advice on how this error message can actually be avoided in Unity 5.6?
As far as I know that warning only occurs if a shader is using the [Normal] property attribute. If your shader doesn't have that, it's possible your shader has a fallback to a shader that does, and at some point you had your shader using the property name _BumpMap and set your non-normal normal map to it on your materials? I'm just kind of guessing though, but it's all I can think of if your shader doesn't have that attribute. You can either add a temporary dummy _BumpMap texture property and set it to none, or go into the material asset and remove the reference there (you can do it from the debug inspector).
@bgolus Perfect suggestion! I don't recall ever having the _BumpMap attribute in this custom shader, but I added it into the properties block and low and behold a few of my materials did have that slot populated with a texture. Unity WTF?! After deleting the textures from the slot I was able to remove the _BumpMap property block as well and now everything works perfect. No more annoying warnings.
I'm getting tormented by this 4 years later. Is there still no other solution besides avoiding the usage of _BumpMap or [Normal]? I'm using a tool that compiles shaders for me and wants to use _BumpMap for normal maps - which is the intuitive thing to do! - and I really want to use it as-is without modifying it by hand after every auto-compilation. Plus it seems like if I do end up changing from _BumpMap, I'll have to dig through all the current materials and clear references first... Unity, please just stop warning me ;_;
My solution was a writing AssetPostprocessor, that closes BumpMapSettingsFixingWindow after found it. Code (CSharp): public class BumpMapSettingsFixingWindowFix : AssetPostprocessor { private static int AskedForBumpMap; private void OnPostprocessTexture(Texture2D texture) { if (AskedForBumpMap <= 0) { AskedForBumpMap = 2; EditorApplication.update += OpenBumpMapCheckWindow; } } private static void OpenBumpMapCheckWindow() { AskedForBumpMap--; if (AskedForBumpMap <= 0) { EditorApplication.update -= OpenBumpMapCheckWindow; var type = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.BumpMapSettingsFixingWindow"); if (type != null && HasOpenInstances(type)) { var wnd = EditorWindow.GetWindow(type, true); if(wnd) wnd.Close(); } } } public static bool HasOpenInstances(Type t) { UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(t); return objectsOfTypeAll != null && objectsOfTypeAll.Length != 0; } }
But be aware that making a new script that inherits form AssetPostprocessor and has OnPostprocessTexture in it will force a complete reimport of all the textures in the project, which can take a loooong time to complete.