CSG in shaders

Hi,

I’m looking for a way to mimic CSG behaviour - cut off part of a mesh by other (invisible) mesh.
My first attempt was to use stencil buffer, but…

  • I use deferred rendering, so no stencil here.
  • I cannot use command buffers (both meshes are already on the scene, as a plain gameobjects) - so my approach must be 100% shader based
  • Both meshes are a part of larger rendering pipeline, so I cannot e.g. add another camera or fiddle with render textures.

Is it possible to achieve something like this purely in shaders?
6737158--776065--upload_2021-1-18_16-29-18.png

Nope.