Search Unity

Normal map with point lights having edge issues

Discussion in '2D' started by nazarre, Aug 13, 2021.

  1. nazarre

    nazarre

    Joined:
    Nov 3, 2019
    Posts:
    8
    I'm using the URP with normal maps to get dynamic lighting in a 2D game but am running into some issues with the sharpness of the edges. See the white cylinder in the center is being shined on by the point light and its edges are showing weird effects (as are the places where the boxes meet). The sprites have Filter Mode 'Point (no filter)' and no compression. Any ideas what's causing this? Thanks!
     

    Attached Files:

  2. nazarre

    nazarre

    Joined:
    Nov 3, 2019
    Posts:
    8
    Here's another example of what looks like some sort of specular reflection that is occurring in the interior of the sprite -- so it's not necessarily a sprite boundary issue, but some sort of interpolation setting that isn't being turned off. Any insights into this are greatly appreciated! anotherex.png
     
  3. nazarre

    nazarre

    Joined:
    Nov 3, 2019
    Posts:
    8
    After fiddling with virtually every setting (ensuring anchor points are the same, PPU, etc all are correct), I still couldn't fix this. However, I did find a workaround (which makes me think there's a bug in the normal mapping code).

    The trick is to use two Point Light 2D light sources attached to the same game object (so they're in exactly the same position at all times). One of the light sources provides illumination, but has its normal map turned off. The other has the normal map box checked, but crucially its Intensity is set to zero (it provides no illumination). This combo works perfectly and all those edge artifacts disappear.

    There must be some bug in the code in which normal mapping coloration interferes with illumination.

    Normal mapping with iso perspective has such possibilities; glad I can use it -- though would be nice to have it confirmed that this is a bug in the code.
     
  4. dzotz

    dzotz

    Joined:
    Nov 2, 2015
    Posts:
    1
    Hey @nazarre, I'm running into this issue as well. I may be missing something here, but if you set your light that responds to normals to have no intensity; while the other doesn't respond to normals, but illuminates the scene -- would that not be the same as just having a single light that doesn't respond to normal maps?

    I'm testing this on my end and the results are the same as if I never used normal maps at all.

    This has been driving me mad for days. Would really value any guidance or clarification. Thank you!
     
  5. nazarre

    nazarre

    Joined:
    Nov 3, 2019
    Posts:
    8
    Your analysis makes sense. Sadly, I can't find this code and abandoned the approach (am now using 3d models with ortho perspective turned on) because I kept running into issues like this and couldn't get things to consistently look good. If I find the codebase I'll look into why it worked and let you know. Sorry for the non-answer though.