Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Light 2D normalmap disabled

Discussion in '2D' started by YupiNawate, Apr 13, 2021.

  1. YupiNawate

    YupiNawate

    Joined:
    Feb 17, 2021
    Posts:
    11
    Hi,
    I am trying to use normal maps with a Light 2D, and it is working in design time... but it automatically gets disabled on runtime. I even tried to set it on during runtime, but the property is readonly and can't be set from a script. Please help!
     

    Attached Files:

  2. YupiNawate

    YupiNawate

    Joined:
    Feb 17, 2021
    Posts:
    11
    Aaaaahm... I dunno if it is about a bug or not, but I found something at:

    C:\Program Files\Unity\Hub\Editor\2021.1.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.render-pipelines.universal\Runtime\2D\Light2D.cs


    There's a boolean serialized field that is set to false:

    [SerializeField] bool m_UseNormalMap = false; // This is now deprecated. Keep it here for backwards compatibility.


    And then, in Awake() we have this:

    if (!m_UseNormalMap && m_NormalMapQuality != NormalMapQuality.Disabled)
    m_NormalMapQuality = NormalMapQuality.Disabled;



    So we have that NormalMapQuality is always set to Disabled. As I said, I dunno if it is a bug, but I found no solution anywhere, no answers in forums and I needed this working, so I changed the initial value from false to true in the Light2D.cs file (I had to grant write permissions to do it), I started my project and I replaced all my spot 2d lights with new instances. Result: working.