Search Unity

NormalMap texture warning grief

Discussion in 'Shaders' started by chingwa, Jun 17, 2017.

  1. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    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):
    1. A Material is using the texture as a normal map.
    2. 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):
    1. _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):
    1. fixed4 texNorm = tex2D (_NTex, UVs);
    2. half3 norm =  lerp( half3(0.5,0.5,1.0), half3(texNorm.r, texNorm.g, texNorm.b), _NormalStrength);
    3. 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?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    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).
     
    Trepidation and chingwa like this.
  3. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    @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.
     
  4. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    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 ;_;
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Good old Unity, shouting at you without you being able to even edit a text file to tell it not to.
     
  6. Tema37rus

    Tema37rus

    Joined:
    Jan 7, 2017
    Posts:
    3
    My solution was a writing AssetPostprocessor, that closes BumpMapSettingsFixingWindow after found it.

    Code (CSharp):
    1.     public class BumpMapSettingsFixingWindowFix : AssetPostprocessor
    2.     {
    3.         private static int AskedForBumpMap;
    4.  
    5.         private void OnPostprocessTexture(Texture2D texture)
    6.         {
    7.             if (AskedForBumpMap <= 0)
    8.             {
    9.                 AskedForBumpMap = 2;
    10.                 EditorApplication.update += OpenBumpMapCheckWindow;
    11.             }
    12.         }
    13.  
    14.         private static void OpenBumpMapCheckWindow()
    15.         {
    16.             AskedForBumpMap--;
    17.             if (AskedForBumpMap <= 0)
    18.             {
    19.                 EditorApplication.update -= OpenBumpMapCheckWindow;
    20.        
    21.                 var type = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.BumpMapSettingsFixingWindow");
    22.                 if (type != null && HasOpenInstances(type))
    23.                 {
    24.                     var wnd = EditorWindow.GetWindow(type, true);
    25.                     if(wnd)
    26.                         wnd.Close();
    27.                 }
    28.             }
    29.         }
    30.    
    31.         public static bool HasOpenInstances(Type t)
    32.         {
    33.             UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(t);
    34.             return objectsOfTypeAll != null && objectsOfTypeAll.Length != 0;
    35.         }
    36.     }
     
    guycalledfrank and atomicjoe like this.
  7. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869


    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.
     
    SUPERHEii likes this.