Search Unity

2D lighting works, just not when i look at it!

Discussion in '2D' started by unity_jxHw6ZCfAkrraw, Sep 23, 2018.

  1. unity_jxHw6ZCfAkrraw

    unity_jxHw6ZCfAkrraw

    Joined:
    Aug 30, 2018
    Posts:
    1
    This is my very first post on the forums, even though i have been reading it for a year now. So please do notify me if this is posted in the wrong section of the forum as i will remove it immediately.

    So I have been working on a 2D game. The game (or at least the intended visuals of it) is best described as a 2D side-scroller (but the game itself is something very quite different). I decided to use the new tilemap feature of Unity. To my surprise, it is worked great! But then I wanted to add fancy lights to it and I can't figure out why it works so inconsistently.

    I wanted to achieve some 2D shadows and some 2D normal mapped magic with unity's built in tools. I made some tiles and normals for them, while I procedurally placed boxes in empty tile spaces, set to cast shadows only. I have also set the tilemap to receive shadows, well, to be able to receive shadows.

    The shadows worked great, the normal maps did put up some fight but after understanding unity's github example, it finally worked too.
    (https://github.com/Unity-Technologies/2d-techdemos/tree/master/Assets/Tilemap/Normal Mapping)

    And here comes the problem that grinds my gears for days now:
    The system works, but not always. Some lights work as intended, that is: they cast shadows and change the textures. But some do not. When zoomed on the malfunctioning lights (lowering the orthographic size) the lights come alive! But not for long as the light gets close to the edge of the frame, it reverts to not working properly.

    I suspect that there is some optimization going on, but i can't find any options that relates to both camera distance and lights.

    I have included some screenshots of the lights working and also malfunctioning. All the lights in the screenshots are exact duplicates of each other. The normal maps are displayed through a simple shader mostly copied from the techdemo example from github, it is attached to this thread too.

    Thanks in advance for any help! Really appreciate it.
     

    Attached Files:

  2. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    maybe in lights inspector: render mode - important