Is it possible to write a shader that creates a hole in another mesh?

I want to create a shader that would create a hole in another mesh. Basically the front faces would mask away the mesh in front of it, while begin drawn fully transparent and the back faces would draw a texture to fill in the space that was masked away. Is this possible? Doesn’t have to be exactly like this. Another solution that would result in a similar effect works too.

You should search for Disable Z Write, your shader would look something as simple as this:

Shader "Custom/DisableZWrite"
{
    SubShader{
        Tags{
            "RenderType" = "Opaque"
        }

        Pass{
            ZWrite Off
        }
    }
}

You should create a couple of render feature in URP asset to mask specific layers and to set a layer as a mask layer

1 Like