Shader For cut hole and alpha blend

Shaders:
Hey guys, just learning shader concept, i am looking for a shader to achieve following Effect:

Say that there is a wall having some texture, if i place a quad in front of the wall, based on the alpha value of the quad texture the wall should be masked,

1)Where there is quad texture alpha = 0 quad has to get the wall’s texture in it
2) Where there is quad texture alpha = 1 quad has to mask the wall completely
(Or vise versa )
3) If the alpha value of the quad in-between 0 to 1 based on that it has to blend(transparent) with the wall.

Similar kind of depth mask effect, but it uses mesh shape to cut the object and results in sharp edges , but in my case i want to use alpha value of the texture to mask the wall.
Hope it makes some sense

There are many many ways to achieve this depending on the needs of your project. Here are a few ideas to get you started:

  • If you only need circles, set uniform vectors on the wall’s material that define where in world space the circles are, in your fragment shader, use a fixed radius, and feather the edges exponentially.
  • If you don’t need an arbitrarily high number of cutouts, define the cutout shapes as extra textures, and use a Vector4 to pack in the texture space x/y and width/height of the shape.
  • For a truly catch all solution, you could render another camera to a rendertexture that captures the cutout shapes and makes that RT available in shader (via Shader.SetTexture). The wall (and anything else that needs the cutout) can get their position in screen space during the vertex shader, and use use their screen space coordinate remapped to the range 0…1 to sample an alpha value from the Cutout rendertexture!

Those examples are roughly sorted in increasing complexity, and also increasing gpu demand. I’d recommend you roll with the minimum solution that will work for your project (though the catch all solution would be a fun experiment/learning exercise)!