Search Unity

Question Why does the Detail Normal Scale apparently change the direction of lighting?

Discussion in 'High Definition Render Pipeline' started by dgoyette, Aug 29, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I wonder if someone could explain why Detail Normal Scale on the Lit shader has the following weird behavior: Adjusting it seems to change the direction that light is coming from, as though I were rotating a skybox around the object.

    Here's an example. In this case, I'm sliding the "Detail Normal Scale" from 0 to 2 under the Detail Inputs section of the material:

    DetailNormal.gif

    This is a simple Lit shader, to which I've assigned a Detail map. The detail map looks like this:

    upload_2020-8-29_19-50-50.png

    So why does it look like the lighting is moving across the surface of the object?

    I make my Detail Maps in Substance Designer, using the following utility:

    upload_2020-8-29_19-57-50.png

    Am I doing something wrong?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Normal map looks wrong.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Can you clarify what you mean by that? I haven't shown a normal map. The image I showed is the Detail map I created. The components of the detail map are shown here:

    https://docs.unity3d.com/Packages/c...ition@7.4/manual/Mask-Map-and-Detail-Map.html

    The detail map contains the R and G components of a normal map, sent into A and G respectively. The other two channels are albedo and smoothness. Maybe I'm misunderstanding which normal map you're referring to.
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Your setup in substance seems correct.
    But I see the texture is imported as sRGB, where it should be linear, and this might explain the bad lighting issue.
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Edit: Nevermind the incorrectness in this past. See my post further down.


    Thanks, I didn't know that made any difference. I tried unchecking sRGB on the texture import inspector, but that doesn't seem to change the behavior significantly. I'd say it looks a little better with sRGB unchecked, but the weird lighting effect is still noticeable. Was there something else I should have done to the texture? I re-exported it from Substance Designer using linear color space, and here's what it looks like in Unity now:

    upload_2020-8-30_10-17-37.png


    I was also wondering if there was some place I could find a Detail Map that's known to work properly, which I could use to verify it's not just something weird I'm doing in generating my detail map? I've also uploaded a lower-res version of the detail map I'm using, in case there's some way to verify it's correct.
     

    Attached Files:

    Last edited: Aug 30, 2020
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Edit: Nevermind the incorrectness in this past. See my post further down.

    Well, it does seem to be something wrong with my actual textures, though I don't know what the problem is yet. I looked in the Spaceship Demo that Unity released (https://blogs.unity3d.com/2019/08/1...fx-graph-and-high-definition-render-pipeline/), hoping to find some detail maps being used. And I found some. I tried using them in my project, just to test out whether it gave me the same weird lighting, but those detail maps actually work properly.

    I don't yet know why one texture works properly while the other doesn't, but I'll dig deeper into how I'm generating the textures in Substance Designer. I'll update this when/if I figure it out, but my current theory is I'm just doing something wrong exporting the textures from Substance Designer.
     
    Last edited: Aug 30, 2020
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Well, I'm not sure what caused me to think that unchecking sRGB on the texture import settings wasn't enough, byut it now seems that all I needed to do. At this point, I don't need to reexport any of my detail maps, I just needed to uncheck sRGB, and at this point they all work completely as expected.

    Thanks for the help with this. It makes me wonder if some of my other issues are due to textures being flagged as sRGB when they shouldn't be. I'll have to read up on why and when I should be using sRGB textures.
     
  8. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Quick general answer for sRGB :
    If it's not to use directly as a pure color information (ex: split channels data, like in the mask map), don't check it, and use linear color space.
     
    dgoyette likes this.
  9. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Thanks. Looks like I've got all my Mask Maps set to sRGB as well, which is probably causing exaggerated metalness and AO on some of my textures. Good stuff to know.