Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted 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:
    3,642
    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:
    3,642
    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.
     
unityunity