This additional shader related question isn't particularly close to the original one, but it doesn't seem worth starting a new thread for.
I noticed that some of the whole-screen shaders have comments like "return black if the resulting coord isn't on screen" and that got me wondering - there are several mods that use weapon graphics, or overlays or ACS to print images to screen (e.g. sniper scopes or the gas mask in my own Burghead mod). Generally, people make these graphics pretty wide to cover as many monitor aspect ratios as possible, but technology and fashion keeps marching on. Screens seem to get wider and wider who knows about future 360 views, the further rise of VR or whatever? So, despite the best efforts of modders, it seems that - sooner or later - a user will be playing with a setup that means that they can see past the side of the sniper scope/gasmask/spacehelmet/whatever and thereby completely ruin the effect.
The gas mask graphic from the original version of my Burghead mod shows the problem if I put in a 21:9 aspect ratio. And at 856x480 I already thought it was wide enough to be future-proof.
(Also, the mod really, really needs to be updated on idgames with my fixed version from the project thread - the number of errors that spewed to the console and the fact that it didn't even go to the correct map on startup when I ran this is embarrassing.)
So, anyway, could this be solved by a scene shader? I'm thinking something like the size of the central image (the scope/mask graphic) can be defined in the shader *somehow* and then, if coordinates fall outside this defined size, draw black pixels to ensure that parts of the scene not covered by the graphic are always drawn black. That way, even if a user has a soopar 1337 (yes, even in the 2020s I just used 1337) 64:1 real world™ wraparound 128K total immersion™ monitor, when they look through the sniper scope/gas mask, they can see what is visible through the viewfinder/lens and the rest of the scene is black.
Is that a thing that could be done? Of course, if it could, I wouldn't even know where to begin but it does sound like something that might be useful as a community resource if someone who knows GLSL could do it.