I found a suitable solution, but the shape is always a rectangle and I don’t know how to get a polygon. I used Light2D in mask mode. Then I set the transparency of light to zero. But in addition to erasing behind the object, the entire Light2D area was also erased.
No, this solution does not suit me. I need to erase everything in the light, not show it. I did not find a way to do the opposite.