So I want to be able to cutout a hole in my mesh - this is for windows in a wall.
The way I am doing it is rendering in separate camera an alpha clipping mask with a camera that just renders the cut-out object in black, and everything else in white, like this:
and here is the result with the cutout in the wall:
That’s all well and good but it has some flaws. The first one I think I know how to fix, is that it will render this cutout even through other wall (see image below). I think if I do some kind of depth test first I can probably resolve this
The bigger issue I have, is that the other walls cannot be seen through the cutout, as these would never been seen in the inital draw, so after alpha clipping they are just invisible, like this:
So what can I do about his? something with stencil buffers? I don’t really know what those are but think maybe they are related to this kind of thing?
Also how can I make sure the shadows also have a “gap” in them, now that light should pass through the hole.
Finally here is the simple shadergraph I am using, thanks




