Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Normal map strength reduced when baking

Discussion in 'Global Illumination' started by FlaxenFlash, Jul 13, 2017.

  1. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    We have recently noticed in our scene that normal maps applied to objects seemed to disappear when we baked them compared to when we lit them with realtime lights. I'm not sure if this is the expected behaviour or if we are doing something wrong but to my eye at least things look dramatically worse once we bake them. Normal mapped objects look flat as if there was no normal map applied to them at all.

    Here is a test scene lit with a single direction light set to realtime. The sphere and the terrain are using the same texture and normal map.


    Switching the light to baked lighting using Enlighten and Directional Mode looks like this. All the lighting variation is gone and it now looks flat. Surely this isn't how this is supposed to work?


    The normal maps are working to a degree. If you set the albedo to a white texture the variations in lighting due to the normals are visible, but they are much less pronounced than they are with realtime lighting.


    Does anyone have any idea what is going on here? Is this a bug? Am I doing something dumb that is causing this?
    I've tried messing with every conceivable setting over multiple versions of Unity from 5.4 to 2017.1 to no avail so at this point any suggestions would be greatly appreciated.
     
    Last edited: Jul 14, 2017
  2. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    Was playing around with this a bit more. Figured comparing the lighting on a sphere verses a quad with a spherical normal map would be a good test.With realtime lighting both look pretty similar:


    But if you bake the lighting they suddenly look very different. The normal mapped quad is noticeably softened and looks less rounded than the real sphere:


    I still don't know what is going on here. I set all this up with a new project so most of the settings are at their defaults. The only changes I've made to the lighting set up were to turn off reflections and indirect light to try and make the test as simple as possible. It seems crazy that directional lightmaps could be this broken and nobody has noticed but I'm equally sceptical that this is how this is supposed to look.
     
    Last edited: Jul 14, 2017
  3. scvnathan

    scvnathan

    Joined:
    Apr 29, 2016
    Posts:
    74
    I don't have an answer for you unfortunately, but have you tested whether the progressive lightmapper gives you the same results?
     
  4. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    I have and unfortunately the progressive lightmapper gives pretty much identical results to enlighten. If there is a problem here I think it is with the directional lightmaps themselves. We did some quick tests on some older versions of Unity and it seems like directional lightmaps have acted like this for a long time, but directional specular used to look better, even with all the objects set to 0 smoothness
     
  5. KevalrOxy

    KevalrOxy

    Joined:
    Aug 15, 2015
    Posts:
    20
  6. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    Thanks KevalrOxy. I had thought about specular and part of my test involved setting the material smoothness to 0 so that there would be no specular highlights. Maybe I just don't fully understand the lighting equations, but I'm not sure how any amount of specular highlighting could cancel out the darkening on the underside of the normal map to such a degree. There shouldn't be any light hitting there in the first place with or without specular so I still think there might be some underlying problem with the directional lightmaps.
    Having said that, using the shadow mask modes might well provide us with a workable solution since they will be providing realtime light to the object which interacts correctly with normal maps so I'll definitely be looking into that.
     
  7. EliasCyborn

    EliasCyborn

    Joined:
    Jan 11, 2017
    Posts:
    9
    bump, have the same problem with 2019.1.1f1... how is this even an issue.
    can't post screenshots due to confidential content, but it looks exactly the same, like my norma maps are just removed when baked
     
  8. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    I submitted a bug about this at the time, but I was told that it was working as expected. We ended up ditching baking altogether because it was too much of a hassle and instead just switched to deferred so we could have all our lights be realtime. This obviously won't be a reasonable solution for most other people.

    Here is the response I got at the time:
    "I checked this issue and the difference is expected because realtime lighting can store all the necessary lighting information for a geometry and a shader can use surface normals to look into it. Just as you did, it is also possible to imitate this by using directional lightmaps in Unity. If you enable directional GI mode, then directional lightmaps can store the information for the direction of light and average of light color. But it is still a limited solution. One thing you should keep in mind are vertex normals and surface normals. Their direction should be somewhat similar, otherwise normal maps and lightmaps can significantly render inconsistent results. So, geometry normals are important for your assets. Now, given that you're comparing a plane with a sphere that has noticeably more vertices and surfaces, the difference is expected. As a workaround solution for your use case, you can try tweaking values or implementing a new solution in " half3 DecodeDirectionalLightmap (half3 color, fixed4 dirTex, half3 normalWorld)" in UnityCG.cginc but in order to keep the system consistent, we don't consider to change this implementation soon."