Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Normal Map to RGBA and just set it to the "_BumpMap" not working...

Discussion in 'General Graphics' started by bansheesoft, Oct 30, 2018.

  1. bansheesoft


    Oct 3, 2014

    (I think this belongs here over the scripting forum. I should have posted here in the first place but at first I was not sure it wasn't a scripting problem.)

    Unity 2018.2.14f1 - Standard shader

    I am attempting to atlas my normal texutures. For now just process one texture. I am simply copying the compressed color stream over to a new RGBA texture.The colors are not changed as they are already coming from the DXTnm swizzles unity creates.

    Once I reapply the new texture (Same exact color layout 1,G,G,R ) it completely breaks the normal mapping as seen above left is correct for testing and right is obviously not working.

    All of this is at runtime as it has to be dynamic.

    Any ideas or hints at what is going on would really help.

    The goal is to atlas my combined skinned mesh renders.
    (This normal mapp issue is the last thing holding me back)

    Simple code:
    Code (CSharp):
    2. public static Texture2D NormalMapToUnityFormat(Texture2D normalMap)
    3.     {
    4.         Texture2D t = new Texture2D(normalMap.width, normalMap.height);
    5.         Color32[] cols = normalMap.GetPixels32(0);
    6.         for (int i = 0; i < cols.Length; i++)
    7.         {
    8.             cols[i] = new Color32(cols[i].r, cols[i].g, cols[i].b, cols[i].a);
    9.         }
    10.         t.SetPixels32(cols);
    11.         //TexTools.SaveToShotFolder(t, "proccessed");
    12.         t.Apply();
    13.         return t;
    14.     }

    I have been at this for days now and I am really stuck. Thank you for viewing.
  2. bansheesoft


    Oct 3, 2014
    Ok so I created an empty project and I am not having this issue?.... there must be some setting somewhere causing this.
    I will keep investigating.

    I should have gone to a new project a long time ago.. Back to research

    Left DXTnm right RGBA like it should be...

  3. bansheesoft


    Oct 3, 2014
    I found what was causing my issue.
    I was not in gamma ligthing mode but linear. Changing to gamma fixed the issue.

    Thanks for all the tips and time... looks like I wasn't as crazy as i thought... -)
    brownboot67 likes this.