There's no built-in extension support in v4, neither it was in plugin, so you have to do your own webgl calls. Also, this extension isnt available on some devices.
However, the thing you want to achieve can be done with basic layering. When you render element, you can render it in multiple layers - just make a container with two sprites. one goes to ambient, one to your "depth texture". That takes care of webgl problems. But its not enough to do what you shown on screen! You need exactly now how you combine layers, house roof and character have to be in different layers!
Layer = container that is rendered in renderTexture separately from everything else.
Use pixi-layers if you want to omit all boring part of code.
For further discussion, please provide minimal technical demo , either in v5 either in v4, doesnt matter if it doesnt actually do your thing. I just cant write 2-hour lection on layers here. I can help with concrete case.
I saw how that depth was made for one of RMMV games, with volumetric fog!
Btw, is there any particular reason you stick to v4?
Welcome to the forums!