Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    41
    channels1.jpg

    (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):
    1.  
    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.     }
    15.  

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

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    41
    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...

    tuy.jpg
     
  3. bansheesoft

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    41
    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.