Search Unity

Question See through mesh with tool Hololens

Discussion in 'AR' started by Sashell_, Jun 14, 2022.

  1. Sashell_

    Sashell_

    Joined:
    Jul 14, 2021
    Posts:
    18
    Hi,

    I'm programing some stuff for AR, and I would like to do this : The player has a tool, let's say a glass plane, and when he puts the plane on a 3D mesh object, he can see inside (everything on the object thats between the tool and the player's eyes is masked).

    It's like i cut through the object, but as i move the tool away the parts that were masked reapears.

    Thing is, I've got no idea how to do that ^^" (I'm working with URP also). I guess this will be a matter of shaders and stuff...

    Can anyone help ?

    Thanks
     
  2. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    What you likely want is a stencil shader that prevents the mesh from rendering wherever the stencil has written to. This would be a custom material on your "glass plane" that should render before opaques (URP also uses this property to do rendering ordering for a given camera) write to the stencil, then your mesh should only render where the stencil has not been written to.

    You might be able to crib off of this shader in our ARFoundation samples
     
    Sashell_ likes this.