Search Unity

CSG in shaders

Discussion in 'Shaders' started by kulesz, Jan 18, 2021.

  1. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    140
    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?
    upload_2021-1-18_16-29-18.png
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Nope.