Invisible Occluder Effect in Unity URP

280 Views Asked by At

I am creating an AR Portal in Unity using URP (Webgl build), and I want an object to come out from it (Like this). I used to do it in the Standard Pipeline using the VR/SpatialMapping/Occlusion shader, which works as a DepthMask, only rendering the color camera pixels and occluding the content behind. However in URP I can't get it to work, I either get black or a smearing effect depending on the URP Settings.

The closest thing to replicate the effect is by using the Stencil, and Render Passes with Stencil comparison. You can see in this images how it currently looks: cube inside portal cube outside portal I need to occlude the part of the cube that is inside of the portal, while still render the cube when it is outside. Does anyone know how to solve this either by fixing the depthmask or with stencil?

0

There are 0 best solutions below