Search Unity

What's the plan for shadow caster 2d and tilemaps?

Discussion in '2D' started by jehk27, Apr 22, 2021.

  1. jehk27

    jehk27

    Joined:
    Mar 23, 2013
    Posts:
    16
    Right now if I add a ShadowCaster2D to a Tilemap it will use the bounds of the tilemap to create shadows instead of using the individual polygons that make up that tilemap.

    I would expect shadows to look like this...



    The above is created using Smart Lighting 2D. To achieve this effect using the 2D URP I'd have to create a separate ShadowCaster2D game objects and manually fit their polygons to each polygon in the tilemap. That is not a feasible solution. Are there any plans to update this?
     
    TheNightglow likes this.
  2. TheNightglow

    TheNightglow

    Joined:
    Oct 1, 2018
    Posts:
    201
    jehk27 likes this.
  3. jehk27

    jehk27

    Joined:
    Mar 23, 2013
    Posts:
    16
    I'm hoping this workaround won't be needed in the near future. I would like to see this functionality out of the box. Add a ShadowCaster2D to a Tilemap/TilemapCollider2D/CompositeCollider2D. Boom. Shadows.
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I just can't believe that there is STILL no support for shadow on tilemap... Or any official announcement that it will be any time soon.
     
  5. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Hi @jehk27, thank you for your feedback and for this screenshot. They help us a lot. We hear all your requests and the 2D team is working hard on shadows interoperability across the different 2D areas including Tilemap. Every use cases/screenshots that you guys share really help us greatly to ensure that our solution would work for you. So keep them coming! :)
     
  6. unity_63934DC3972265230245

    unity_63934DC3972265230245

    Joined:
    Aug 1, 2021
    Posts:
    1
    Hi @Xiangting_Su has there been any update to this? I'd love to be able to set up lighting properly in a tile based environment.
     
  7. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Yes I do know there has been a significant progress for Tilemap shadows (and shadows in general). I haven't been made aware of any estimated release dates yet but I do know there have been some promising shadow developments.

    I'm curious too, what kind of games are you working on/have in mind? Or how would you like to use shadows on Tilemaps once it gets released? Just so we understand all different use cases better.
     
  8. TheNightglow

    TheNightglow

    Joined:
    Oct 1, 2018
    Posts:
    201
    I would love if one could simply add some shadow caster component to a tilemap with a TilemapCollider2D or CompositeCollider2D, and than that collider gets already recognized for the shadow generation

    with this:
    https://forum.unity.com/threads/script-for-generating-shadowcaster2ds-for-tilemaps.906767/
    you can generate shadow casters for all open tilemaps in scene that have CompositeCollider2D using a button in the UI

    that works aswell but is a bit less intuitive then simply marking the shadow casting objects and have anything beyond that automatic

    ---------------------------------

    something I noticed when setting up a top down scene with 2D shadows, is that certain objects are not really supposed to cast shadows in every direction...
    and different objects should have a different shadow length

    for instance for a cliff wall, shadows should act differently whether the light is on top of the cliff, or below

    here a quick example:
    Light below cliff:

    light above cliff:

    for the first image, it is fine that everything above the cliff is shadowed, since the light would not reach there with the source being below
    for the second image, it would be nicer if the rocks either dont cast a shadow at all, or one that has a smaller length, as in only the area close to the rocks being shadowed

    I really dont know how something like this would be best presented to the user, since the shadow direction and length would need to be part of the tile info, generating a shadow caster from collider alone would no longer be enough...

    maybe this info could be defined in Rule Tiles, with each rule having an advanced definition option to declare which direction casts which length of shadows?

    beyond that, just shadow length in general would be appreciated, makes no sense for a tree and a bush to have shadows of the same length (while right now, I think every 2D shadow caster always has an infinite length)
     
    Last edited: Oct 20, 2022
  9. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Tilemap Shadow Support
    Thanks for sharing! Yes! Making use of the Tilemap Collider and Composite Collider is one of the many use cases the team is testing to support.

    Light Directionality
    Yes, this is true too and I agree on the need for directionality support in most 2D Lights (probably except Global Light which is like a an omni light that casts rays in all directions from a single source). Debatable of course. This has been feedback to our team previously and is already in the team's backlog. I'll also share your use case back with the team and note it down in our 2D Product Board.

    Shadow Length
    Absolutely. It makes sense for taller objects to cast longer shadows i.e. the cliffs to cast a longer shadow than say, the smaller rocks. The ability to tweak the shadow length (and maybe even to determine shadow length based on certain properties) is also in our team's backlog and is definitely worth exploring.

    Thank you for the screenshots too. They are super helpful!
     
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    It's been like 7 months... what's the status of tilemap shadow? It this ever going to happen really? It's been so many YEARS that this was requested.. (now I forgot because it has been sooo long) No updates, and still no tilemap shadow?
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    Kirsche likes this.