Is there any way to check if a pixel is within a mesh, either in 2d or 3d?

I am working on a 2d line of sight inplementation in a top-down game. I have a function that generates a 2d custom mesh describing the visible area.

I’ve already implemented a post process that masks out pixels behind the mesh using the custom depth buffer. What I want to do is find a way to mask out pixels BENEATH (z direction) the mesh, either by projecting each pixel downwards, or extruding the mesh vertically and checking if each pixel is INSIDE the mesh. Basically what I’m trying to do is a volumetric post process with an arbitrary mesh.

For specific case, render the mesh into a top-down depth capture.

As a general case, to check if fragment is within an arbitrary shaped bounds, you need to render bounds mesh into two depth buffers, with front faces and backfaces correspondingly, then test fragment depth against two depths that are stored.