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

Selective Shadow Casting?

Discussion in 'General Graphics' started by cooperjknapp, Nov 8, 2021.

  1. cooperjknapp

    cooperjknapp

    Joined:
    Jun 28, 2019
    Posts:
    3
    Howdy! I've been trying to optimize the lighting of one of my projects recently, and I'm having trouble with it. Basically, the solution I've found requires my lights to only cast shadows off certain objects, but still light all the others. Here's the specific problem I'm facing generalized:

    I need Light A to cast shadows off Object A
    I need Light B to cast shadows off Object B
    I need Object A, Object B, and Object C to be lit by both Light A and Light B
    (technically, Object B doesn't need to be lit at all, as it's not being seen by the players and it's simply acting as a shadow casting agent. But for sake of simplicity, I wrote it as you see above)

    I've tried many different options using light culling masks and adding more lights, and etc etc etc. I couldn't solve it that way. Additionally, this problem can't be solved by turning off shadows for some of the objects, as they need to be used by the other light. I'm using the default Unity Rendering Pipeline, whichever one that is. So:

    Is there a way that I can selectively choose what objects a given light uses to cast shadows? Similar to the light culling mask but in this case only to choose which objects are being used to cast shadows.