Search Unity

Feature Request Force a bigger shadow distance for all objects in the scene that are lit by specific light

Discussion in 'Editor & General Support' started by swantonb, Sep 30, 2022.

  1. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    172
    Hi, it seems impossible to get a flashlight in any kind of multiplayer game, either fps or whatever. The only way is to make shadow distance infinite which is inconvenient for any game that wants to achieve performance as well.

    https://www.reddit.com/r/Escapefrom...hey_ever_going_to_fix_the_flashlight_through/

    This is what I'm talking about. Tarkov seems to not use distance shadowmask in this scene or maybe they do, but the shadow distance is way too small, or they dont cast shadows for the flashlight neither, but in my game i do use a 20 meters shadow distance by default, but the user also has the setting to adjust however they like. So the user can even make the shadow distance to 5. That would cause a flashlight to be noticed through walls unless the other player that has the flashlight on is within my shadow distance range. Even at 50 shadow distance, or 100 or 200, which would definitely kill a scene's performance, if the other player that has the flashlight on is farther than that shadow distance then the flash will go through walls and the player's location would be blown. Basically flashlights are no way to be used in a multiplayer game and that is kinda not nice. We could get away with it in a PvE game, where players might not care that the light is going through walls, as long as the AI will not detect them for that. So for multiplayer games setting an infinite radius of shadow distance and using distance shadowmask or baked indirect is actually unusable, since it would kill performance.

    I've also tried to hack it by sending a raycast from the flashlight to a wall it hits, then decreasing the range of the light but the result is awful and it is not really working neither. The light would still pass through walls on diagonals. Also I lerp the range of the light when it changes, to not look absolutely awful and that doesnt really help with the passing through walls neither, and its disturbing too when you see the light focusing on the objects that you hit the raycast with, especially when there is some kind of fence around, and the raycast hits a part of the fence, then it hits more into the distance.

    The only soultion I can think of is forcing an infinite shadow distance for specific lights (flashlights) on all the objects in the scene. It might still pe performance costly but its not remotely comparable to using distance shadowmask with an infinite shadow distance or baked indirect, considering that only some of the meshes in the scene (the ones that are lit by the light) would actually become shadow casters

    Can we have this, Unity team?
     
    Last edited: Sep 30, 2022