Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Strange result from specific configuration: Perspective Camera + Normal Map + Rotated Sprite

Discussion in '2D Experimental Preview' started by Jamez0r, Feb 5, 2021.

  1. Jamez0r


    Jul 29, 2019
    Figured I'd post about this in case anyone else runs into the same issue. Took me a couple hours to figure out what was going on here :eek: I'm not sure if its a bug or not.

    The issue:
    The normalmap for this Player character would become 'offset' seemingly randomly:

    The setup:
    1) Project is using a Perspective camera (so we can parallax easily).
    2) A Light2D as Point Light with Use Normal Map selected (its positioned near the Player's feet in the screenshot)
    2) A big grass-sprite that is underneath the Player. It is rotated on the X-axis.
    3) The Player character who has a normal-map on top of the grass. Nothing rotated or anything abnormal with this.

    I had accidentally rotated the grass-sprite beneath the character. If you are using a Perspective camera, with the 2D Lights, with Normal Maps, then rotating a sprite on the X or Y axis causes the normal-map to become offset/skewed. Here is the Frame Debugger at the step where the rotated-grass sprite was drawn:

    Another thing worth noting is that a similar behavior (normal-maps becoming 'offset') happens if your Perspective Camera itself rotates on the X or Y axis. I don't imagine anyone should be rotating the camera like that for a 2D game, but just wanted to mention it - if you accidentally let the camera get rotated even a little bit, everything with the Lights will get out of whack (at least if you're using normal-maps).

    Hoping that the "Use Normal Map" part of the 2D Lights system gets a little TLC - there are a couple weird behaviours with it, such as the "Distance" value affecting falloff, etc.