Search Unity

Question Help with 2D lighting and tilemaps - UDR not working as expected

Discussion in '2D' started by GameDevSA, Aug 10, 2023.

  1. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    I have a game I am trying to set up for 2D lighting with the Universal Render Pipeline. I am also using the Super Tilemap Editor asset from the asset store. I followed this tutorial to try and get started with 2D lighting:


    I'm using Unity 2019.4.33f1 LTS.

    I followed his instructions:

    1. Import the Universal Render Pipeline package
    2. Create > Rendering > Universal Pipeline > Pipeline Asset (Forward Renderer)
    3. Create > Rendering > Universal Pipeline > 2D Renderer
    4. Drag the 2D renderer onto the Renderer List of the new Universal Pipeline asset
    5. Edit > Project Settings > Graphics > Change the render pipeline asset
    6. Edit > Render Pipeline > Universal Render Pipeline > 2D Renderer > Upgrade Scene to 2D Renderer
    Initially only some things went black, most still looked like regular "unlit" sprites, ie, not affected by lighting. I realised it's because they were using a sprite shader that was unaffected by lighting, so I made a new material that uses the default UDR 2d Sprite Lit default.

    So, if I drag a new sprite onto the scene, it uses that material by default, and is black and fine. When I updated the material in my Super Tilemap Renderers, I have mixed results. Some of the tilemaps go all black, some are unaffected. Picture example.

    upload_2023-8-11_0-39-41.png
    List of tilemaps in the heirarchy

    upload_2023-8-11_0-39-57.png
    Tilemap renderer with correct material

    upload_2023-8-11_0-39-9.png
    Result

    I added a point light over where there should be water, and you can see a soft circle of water fading into shadow where the point light is.

    But all of the palm trees outside of that, as well as the waterfalls, the sand and rocks, etc, should be black, they are not lit. At first I thought it's because I pained some as prefabs, and made sure to go into every individual prefab (the waterfalls are all prefabs) but it made no difference. Likewise, the trees are not prefabs.

    The only pattern I can see is, the top tilemap in my heirarchy is behaving properly, the rest are not. Base is where the water is, and that entire layer, which is using both prefabs and non prefabs for the tiles, the whole tilemap is behaving properly with the light. None of the other tilemaps are.

    upload_2023-8-11_0-43-6.png
     

    Attached Files:

    Last edited: Aug 11, 2023
  2. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    I just did an experiment and turned off all my tilemaps in the scene. I then made a new tilemap. It behaved properly with the light. I then made a second tilemap. It did not behave properly with the light. There really does seem to be a limit of 1 tilemap only working with a light source at the moment.
     
  3. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    I also got this error when upgrading the super tilemap editor, not sure if it's relavant: upload_2023-8-11_12-18-58.png
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    try without using the 3rd party asset

    also what it looks like is that the parts that are not black dont have the same material
     
  5. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Thanks for your reply. So, the material on all of them is the same. I did make a brand new material to make sure that wasn't causing issues (initially it was), but now they are all using the same material and that didn't fix it. It seems like the top tilemap works, and not the others, which makes me think it could be either a bug, or I've set their tilemap up wrong.

    You're right though. I've started experimenting with Unity's own tilemap system, and saw that it's finally added a lot of the features it was originally missing, like painting prefabs, random brushes, etc, so that might be worth a go.

    However, I am still having another weird issue with rendering in the scene view, which I have no idea what has caused it, but I suspect it's a setting, and may be because I upgraded this project from an older version of Unity, I'm not sure. That post is here: https://forum.unity.com/threads/universal-render-pipeline-screen-tear-ghost-image-help.1472289/