AR Masking with UniversalAR and A-frame

Hi guys how can I apply masking shader/effect to geometries and gltfs on webAR / A-frame ?

So to do stuff like a portal or make objects go behind a package with image tracking ?

Thanks in advance

If you set an object’s material.colorWrite property to false, it won’t get drawn visibly to the screen, but it’ll still occlude/hide other objects behind it. So if you have a cube in the distance, and a small sphere closer to the camera but with its colorWrite set to false, the cube will seem to have a hole in it where the sphere is in the way.

To make a portal effect, you’ll need to create a mesh with a portal-shaped hole in it, like a big wall with a window cut out. As long as that mesh is placed in front of any other objects in your scene, you’ll only see those other objects through the mesh’s “window”. You don’t want the “wall” part of the mesh itself to be visible, so set its colorWrite property to false - it’ll still hide any 3D objects behind it, but the camera feed background will show through