I'm trying to implement a visibility representation in a 2D game ( no plains, no quads - plain 2D ) In the examples below I have calculated what the player can see using raytracing and added all the colliding points as vertices to a polygon 2D collider. What is within the polygon is in view.
I want everything outside this visible area to be darker / faded out / fogged out, so that it is not visible / as visible as what is in the view. Prefably I would want to choose what objects are included in this darkening, so that static enviroment is not affected but enemy players are.
Simply deactivating the object's renderers is not an option. I also though about overlaying a texture and using a cutout alpha mask, but that would not translate well considering that the visible polygon is updated every frame and the mask has to be premade(?).