Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Baked Normal Map Issue

Discussion in 'General Graphics' started by Cramonky, Jul 25, 2015.

  1. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    181
    Hey,
    So I've recently discovered a problem in Unity involving baked normal maps, particularly when it comes to flat surfaces.

    Here is a brick model in Blender with the low-poly with a baked normal map on the left and high-poly on the right: http://gyazo.com/f0ccebf10250f4275797a213e529b14e

    As you can see the normals on the low poly are correct. However when i import these models into Unity it looks like this: http://gyazo.com/413f5c117420f279a2ade6a0f48ad1da

    Theres also issues on the corners as well that are present in Unity but not Blender:
    Blender: http://gyazo.com/80d1312e48f321fbec708cbc3b3e5ca3
    Unity: http://gyazo.com/c70f227cf715c00c0fffcc429b98ebb1

    There's some weird shading going on on the flat parts of the low poly, even though the models and textures are exactly the same. I'm not sure what's going on since Blender's render is fine but Unity's isn't...

    UPDATE:
    I was able to solve this by checking the "Tangent Space" export option in blender and then set my model in Unity to import tangents instead of calculating them.

    I may have spoke too soon... It looks like almost every face on the cube I was using to test is fine: http://gyazo.com/560dc99a67d1bc34660b9e0577afea61
    Except for ONE face: http://gyazo.com/58c0c3683cf05bdb327bfe91c0ff0492
    Now i am just really confused.

    Also I found out that I have to use XNormal to bake or else all the faces will look weird like they did before.
     
    Last edited: Jul 26, 2015
  2. PropositionOne

    PropositionOne

    Joined:
    Jul 25, 2015
    Posts:
    13
    There's no universal scheme for normal maps. I believe I've encountered this problem before and it has something to do with blender using a different-handed coordinate system than Unity which results in normal maps being baked incorrectly for Unity's scheme. I believe I had to write a program to flip one of the axes on my normal maps from blender - I can't recall.

    EDIT: here: http://answers.unity3d.com/questions/28850/tangent-normal-map-produces-reversed-effects.html
     
    theANMATOR2b likes this.
  3. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    181
    That doesn't seem to work for me. I don't know if I am skipping some steps here but I'm not getting good results at all: http://gyazo.com/003110cf2b5399ede9a21b3e65739b7a

    I baked the normal map in blender normally, then inverted the red and green channels in gimp cause I'm not really familiar with Blender's image compositing (plus that section on the Blender wiki is really bad and outdated).

    This is the normal map blender generates: http://gyazo.com/61fa193ec6f869a7177797df302ea242
    And this is the result of inverting the red and green channels in gimp: http://gyazo.com/a6c80335469ba76ccf1208f38cdd2076

    I'll stick some more reference pictures here so you can see the results i'm getting from other methods:

    Blender unmodified normal map: http://gyazo.com/265800d99b358b7a87e7e219347bf494
    Xnormal map: http://gyazo.com/e3e1940c0339d352ab30d6a88724f8e0 (Some faces such as the right face look OK while other faces have issues like the left face).

    This model was exported with the tangent space option checked and is using imported tangents in Unity.
     
  4. PropositionOne

    PropositionOne

    Joined:
    Jul 25, 2015
    Posts:
    13
    Hmmm... well, I just baked some normals in Blender 2.72 and they seem to be working fine (unmodified) in Unity 5.02:

     
  5. PropositionOne

    PropositionOne

    Joined:
    Jul 25, 2015
    Posts:
    13
    Your problem with importing cubes into Unity might be that you have them set for sharp edges in Blender which won't import into Unity without using the "edge split" modifier. Unity will take the mesh as you assigned it, with only one vertex per corner resulting in a normal vector that points diagonally from each corner away from the center of the cube. What you need to do is separate every face of cube before you export it so that there are three vertices per corner, not one.
     
    Last edited: Jul 28, 2015
  6. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    181
    Last edited: Jul 28, 2015