Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Bug Bug or intentional? 2D PointLight with "Use Normal Map" treats rotated sprite like its 3D

Discussion in '2D Experimental Preview' started by Jamez0r, Aug 23, 2020.

  1. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
    Hello, I'm working on a 2D overhead-view game. I use the 2D Lights and use normal-maps on some of my sprites (not all), so I have "Use Normal Map" checked on my Point Lights.

    When we set up our level maps we sometimes rotate sprites in 3D space to get a specific angle for the sprite.

    When "Use Normal Map" is NOT selected on the Point Light, it acts normally to light the sprite.

    When "Use Normal Map" IS selected, the light treats the sprite as though it is a 3D Plane. So the light that lands on the 3D-rotated sprite is skewed.

    Is this a bug or intended behavior? I would really like to be able to rotate sprites when building our maps. I understand that I can achieve the same "shape" by scaling and rotating the sprite about the Z axis, but that takes much longer to do. We are making high detail maps with lots of layers.

    In the following screenshots, the sprite for the white-stone circle is a perfect circle, but we rotated it on the X axis to make it fit the perspective a bit better as a wider oval shape. (again, I understand we could have scaled down the Y axis instead of rotating, but this is the most straightforward example. We rotate other things on multiple axes)

    This screenshot is showing where the Point Light is positioned:


    This screenshot has Gizmos turned off so you can see how the light is skewed downward due to the sprite's rotation. The Point Light has "Use Normal Maps" enabled:


    In this screenshot I turned off "Use Normal Maps" (and turned up the Falloff Intensity to match the intensity better). You can see that it is a normal circle shape, as desired:
     
  2. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
    Thinking about it a bit more, and I understand why the rotation of an sprite with a normal-map should update the lighting on that object. If I had a sprite with a normal-map, and I rotated the Z-axis 180 degrees (or if I made its scale negative), the angle of the normal map should take that into account. So I can see why even the full 3D rotation would need to be accounted for when sampling the normal-map.

    But the 'skew' of the shape of the light is confusing me. I don't see why the shape that the light 'falls on' the sprite shouldn't be treated as though it is 2D. AKA I'd expect a point light to be circular no matter what, since this is a 2D Project with a custom 2DRenderer.

    Also I'm surprised that the white stone ground-floor sprite is treated this way at all, since it doesn't have a normal-map.
     
    Last edited: Aug 23, 2020
  3. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    191
    There are some known issues with point lights, does this still happen if you change your point light to a parametric light?
     
    Last edited: Sep 21, 2020
  4. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
    Hey Chris, thanks for the reply!

    Looks like the Parametric Light is also having the same effect.



    Might be worth noting that (for me at least) the skew wasn't noticeable with the default Distance (3), and that as you lower the Distance the skew effect becomes more apparent.

    Thanks for taking a look!
     
  5. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
    Hi @Chris_Chu - was just taking another look at this and realized that this 'skewing' of the 2D Lights does not happen if the 2D Light & Sprite are on the Default Layer. It only happens on additional layers that you add.

    I submitted a bug report through Unity with a repro project - I'll post the Case Number when I receive it. Would seriously appreciate anyone taking a look at this as its making our environment look really janky :eek:

    Thanks a lot!!
     
  6. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    191
  7. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
  8. renanssba

    renanssba

    Joined:
    Feb 22, 2014
    Posts:
    7
    Hello, sorry to revive the thread, but I'm having the same issue in my project. Is there any update to this bug?
    Did you find any workaround, Jamez0r?
     
  9. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    176
    here is the bug ticket: https://issuetracker.unity3d.com/is...g-normal-map-and-sorting-layer-is-not-default

    Says "Fix in review for version 11" (assuming they mean URP).

    I do not have a workaround yet. I am actually actively trying to figure out how to convert 3D rotation into this 2D 'shear' setup, for both the reason mentioned in the thread as well as this 2D-lighting issue: https://forum.unity.com/threads/any...n-to-this-unique-2d-skew-shear-setup.1032409/

    Haven't had any luck yet. You can use that shearing setup but its difficult to get it into the position you want quickly.
     
unityunity