Search Unity

Question Shader thinks floor tile has no light at certain angles

Discussion in 'Shaders' started by Jinxology, May 29, 2023.

  1. Jinxology

    Jinxology

    Joined:
    Jul 13, 2013
    Posts:
    95
    I'm having a strange issue on my floor tiles where sometimes a whole corner of the floor tile is shadowed completely. It seems to occur when 2 point lights are overlapping a bit.
    Here's what it looks like when things are okay:
    lightingCorrect.PNG

    And if I back up slightly, or change my angle slightly, it sometimes does this below. You can see how the tile gets shaded black exactly along the edges of it, but the neighboring tile is lit correctly.
    lightingWrong.PNG

    Any ideas on what may be causing this? It's correct when walking around 80% of the time, but that weird shading flickers in and out as you move about.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I would try and check it out using the frame debugger or RenderDoc. Assuming this is the built in renderer, see how many times that object is rendering (it'll be once for the base pass, and once for each additional light) when working properly, and when not working and see if it's the same or different. If it's not rendering the same number of times, for some reason it doesn't think it's getting hit by that light. If it is, then one of the lights is broken, or there's another light in the scene that's "winning" sometimes and it's choosing to render with when it shouldn't.

    You could also try increasing the max number of per pixel lights to see if it fixes it, which will also tell you if there's an extra light in the scene you're not taking into account.

    If this is the URP, then you can do the same, but you'll have to dig deeper into the data to see how many and which lights the tile is rendering.
     
    Jinxology likes this.
  3. Jinxology

    Jinxology

    Joined:
    Jul 13, 2013
    Posts:
    95
    I am using URP. I changed the number of per pixel lights to 5. You're right! There WAS a light I wasn't considering that was causing the issue I believe. I wasn't even aware of that setting. That fixed the primary issue on the floor tile. In my limited knowledge, I think that was the main issue: It was changing it's mine on which light to use to render the pixels, so the shading would change sometimes. Is there a big cost for upping that number to 6? I don't think there will be that many in very many places anyway.