The shadow mask is calculated based on the shadow depth map algorithm in Material and Niagara.
You can download and check it if interested. https://github.com/proceduralit/ShadowMask
Material & Niagara
Shadow Parameters