Search Unity

Question What are the specific rules for whether a light will be occluded?

Discussion in 'General Graphics' started by dgoyette, Jan 18, 2021.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I was noticing very high CPU usage on one of my levels, which ended up being a lot of lights being prepared. Looking into it further, I'm finding a lot of lights are on, even when I expect they should be off due to occlusion culling. Here's a good example. Here the camera is on the far right of the screen, and it's generating completely reasonable visibility lines. On the left, you'll see a couple of spotlights I've selected, which are pointing away from the part of the scene visible to the camera. Yet, the lights are still on.

    upload_2021-1-18_16-23-56.png

    If I rotate the camera away from this direction, then the lights shut off. But I don't understand what's causing these lights not to get turned off via occlusion culling in this case. The lights are outside of the volume of visibility lines, and the cone the light generates doesn't overlap anything in the visible region. If I reduce the range of the lights, they do eventually turn off.

    I haven't been able to figure out what rules are keeping those (and several other) lights on. It seems like the occlusion rules for lights are that they will be on if their influence volume overlaps at all with the volumes created by the visibility lines. But these lights seem to be very much out of range, and pointing a different direction.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I still don't have any real sense of the rules governing occlusion culling and spotlights. I think I understand how things work for point lights, but not spot lights. For point lights, it seems like it's just a matter of whether the sphere the light creates (based on its range) overlaps at all with the camera frustrum. However, for spot lights, I don't see a clear pattern.

    Here's a simple view of a scene where I've selected a light which is definitely on, in relation to the camera frustration that should be occluding it. I know it's hard to see what's happening here, but hopefully it's clear that the spotlight's cone doesn't overlap the camera frustrum at all:

    LightOcclusion.gif

    I thought maybe spot lights were taking a shortcut and just using the same approach as point lights, and acting as though their radius was for a complete sphere. But in this example, I can set the spotlight's radius to about double the radius of a point light before it stops being occluded. So, it has to be some other approach.

    Anyway, I'm just trying to understand this better, so I can make more informed decisions on my light placement. Currently, I have a lot of lights that are being rendered when I would have expected them to be occluded, and I'd like to understand this better instead of just having to trial and error my light placement.
     
  3. robconnell

    robconnell

    Joined:
    Jun 8, 2020
    Posts:
    11
    my fix for this was creating trigger volumes that would deactivate any lights not needed when in that space. an extremely hands on approach and probably not the best but it did get me through with a definite answer to the problems. It seems as though lights just don't really cull the way objects do. maybe do to the fact that unity is needing to process the effect of the lights even if off screen. I'm really not sure.