Search Unity

rotated normal map png in photoshop, artifacts in edges?

Discussion in 'General Graphics' started by mgear, May 6, 2021.

  1. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    if i duplicate normal map png image file, rotate it 90 degrees inside photoshop,
    then i get those yellow lines.. whats happening?

    upload_2021-5-6_16-25-8.png

    (same import settings)
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    Can you post the original png normal maps?
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    this one,
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    I was not able to reproduce it initially. So there's nothing obviously wrong in Unity's handling. Tried 2019.2 and 2020.3.
    upload_2021-5-6_12-33-56.png

    I suspected the problem is the texture has alpha, and Photoshop's default PNG handling is to kill the data in the areas that are fully transparent. It's not a problem for the middle bands because it replaces those areas with a solid color value from the areas around it. But at the edge of the texture it's going to replace the RGB color with solid white. Putting that through the normal map packing & unpacking where the Z (blue) is thrown away and reconstructed gets you that yellow color.
    upload_2021-5-6_12-40-15.png

    The short version is, never use Photoshop's default PNG file handling. Use SuperPNG and make sure you open the file with the alpha as a separate channel.
    https://www.fnordware.com/superpng/
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    ok must be those then, thanks for the info! (also yeah, rotation wasn't important here, just saving it out causes it)

    upload_2021-5-7_5-52-17.png

    tried all kind of combinations of loading / saving (superpng also) but didn't make much difference,
    i guess will have to rotate the model UV map instead of this texture.. :D
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    You need SuperPNG, and you need to read the instructions that come with it. ;)

    Mainly, hold down shift when opening to get the options dialog and change it to open transparency as a separate channel. And when you save do the same but make sure clear transparency isn't on.
     
    Last edited: May 7, 2021
    mgear likes this.
  7. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    aah! well that was too easy.. : D

    upload_2021-5-7_7-25-19.png