Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shadow Caster 2D "Self Shadows" not working when the object is a certain distance away from light

Discussion in '2D' started by PixelDough, Dec 15, 2021.

  1. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    55
    I'm prototyping some 2D mechanics and I thought it would be cool to use the new 2D lighting features. However, I started seeing sprites I'd placed lose their self-shadowing. If I brought the sprites closer to the light, they'd regain their self shadowing. And if I stretched the sprites away, they'd lose it again. It seems to have something to do with the center of the sprite and it's distance to the light? I tried fiddling around with all kinds of settings to see if maybe turning up the shadow resolution would work or anything, but found nothing helped.

    If you look at the pics I have attached, you'll see what I mean. I stretched this wall piece out to demonstrate how it's origin is just outside the reach of the spot light, and that causes it to no longer produce shadows of any kind.
    upload_2021-12-15_12-25-13.png upload_2021-12-15_12-25-59.png

    Is there anything I can do to fix this? Or is this the intended behavior that I should find a long term way to work around?

    I am using Unity 2021.2.5f1, if it matters
     
    Last edited: Dec 15, 2021
  2. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    55
    I've also found that having a small spot light somewhere in scene with an outer radius smaller than 1.615168 causes spot lights elsewhere to no longer cast shadows at all. For example, here's a before and after of a spot light with a radius of 1.615168 and a radius of 1.615167 (0.000001 smaller than the threshold):
    upload_2021-12-15_14-55-20.png upload_2021-12-15_14-55-58.png
    You'll notice that those walls are no longer casting shadows despite the fact that the only other light in scene is both far away and tiny.

    I'd love to use the 2D lighting systems but if everything simple I try to do has these awful artifacts, I'm going to look for other options.
     
  3. DouglasAsted

    DouglasAsted

    Joined:
    Aug 10, 2018
    Posts:
    1
    Did you find any solution to the problem?