2D perspective based rendering

I wonder how i could make a 2D world so that only stuff that is is visible to the player is rendered to the screen, and also is a bit brigthened. See image below:

Im fine with the terrain always being rendered (the terrain will probably have colliders and is what will make the shadows) but how could i make it so that, like in the picture above, only the black parts of the “enemies” are visible? Should i do this with shaders? I am really curious, If you have any solution that almost solve the problem or that you think i might be intrested in, please share them as well. Thank you!

You could try something like this? The author provides source code and a demo if you scroll down a bit.