shading mask stereographically

Hi guys,
does anyone of you know how to program a shading mask stereographically visualized in three.js? If so, what would be the best way to do it?
Here is a sample PD: Shading Box if you struggle to understand what I mean.