I was wondering if there was a way to make a 2D shader (or use any other method) to selectively black out areas of the screen that are not in a specific region.
I need this shader because in the game I am making, I would like the area outside of the player's current room to be obscured, except when the player is transitioning between rooms, at which time both will be visible for a while, after which the old room fades to black. You can seem a diagram of this below.
I have tried accomplishing this by simply fading in and out textures depending on which room the player is in, but the problem with this method is that if these textures overlap, while the rooms are transitioning, the areas where they do overlap will be darker than the others. Likewise, attempting to set up these textures to account for all possible room entry/exit scenarios without overlap is complicated, error prone, and time consuming. This is compounded by the fact that certain parts of the map should be visible from multiple rooms. I have also tried using a simple shader that darkens all pixels in the old room, but that doesn't work because, as mentioned before, some areas are visible in multiple rooms.
Thank you for any help you can give! I understand that this might not be a simple thing to make, and I've had a lot of trouble describing what I'm looking for, so I'm totally happy to clarify further if need be.