Shader Depth Mask - is it possible to limit its distance?

I am using the depth mask the enables objects behind it to become transparent. Is it possible to limit its effects to objects near it, instead of everything. I want to like a window, but if i look through a window at another window its walls are gone. Even a nudge in the right direction would be appreciated!

Shader "Depth Mask" {
         
             SubShader {
                 Tags {"Queue" = "Geometry-10" }
                 
        			
                 
                 Pass {Lighting Off
                 ZTest LEqual
                 ZWrite On
                 
        			ColorMask 0}
             }
         }

To answer my own question, I just added a script to my camera and my walls, the camera script checked if any new windows had been added to the screen, it would then tell the window script to change its render queue based on the distance from the camera, it would also change the render queue of the walls it intersected with to correctly layer the depth. By checking if a window was added I was able to eliminate any frame rate issues.

Only issue I have left is updating the depth layer if i change direction but the window count stays the same.