I got a project to draw a hole(transparent cube) on a wall, but the hole could be any shape and any size, and maybe out of the wall. And I'm tried to use blend to override the existing wall, absolutely, this could not work correctly.
In the project, the walls are drawn with instancing method DrawArraysInstanced
, and the transparent cube is drawn with instancing method (this isn't essential, there should be DrawArrays
in the future), too. And I tried to use StencilFunc
and DepthMask
, but could not figure out how to do it.
Briefly, Is there an approach to draw rectangles by instancing and then cut small rectangles on some rectangles (I mean some instanced rectangle have a window)? Noticed that the shape that cut rectangles could be any size and type.
Any advice and suggestions would be greatly appreciated, and If the question is not clear, please let me know.
Edit:
I know the practical way is to calculate the shape intersection to get the triangles and using DrawArraysInstanced
to draw the triangles with those object that cutted holes, but I just want to know If there is a tricky way to make it work.