How to make fog of war like war3 in 2d game

I know how to make fog with serval textures like war3 did in terrains but it has only 2 status:unvisible/visible.

My fog should have 3 status:unvisible(black)/can be detected(light black)/visible. So I want to know exactly how to make the fog like war3.

Now I use a mask texture, and draw rectangle in it,then use shader to blur it.But the mask does not look well.

A popular approach is to build a plane mesh by code above the terrain, apply a black texture to it, and then raycast upwards from each unit. Any triangles that are hit have their corresponding vertices’ vertex colors set to alpha = 0, or whatever color you desire.