To properly display 3D models such as glasses, hats, etc. parts of the model need to be occluded by the user's face. To achieve this prepare a mesh to be used for occlusion. Depending on the use this can be the reference mask model, a full head model, or any other shape. Here is a cylinder (white) which we will use to occlude the helmet and straw.

Mesh for occlusion

First, we must ensure that the occlusion mesh is drawn first in the same layer as the objects being occluded. Meaning if the occlusion mesh has the following (default) Node properties:

Then all the objects being occluded will need to be in the 2nd layer and have a Depth of 1 or greater.

For occlusion the selected mesh needs to write to the depth buffer, but be transparent so that the camera texture can be seen through it. To achieve this select the material for the occlusion mesh and in States & modes uncheck the RGB write option and ensure the Depth write option is checked. For best performance, also disable Alpha Write, Set the blend mode to Off and select a simple shader such as Unlit color for the material.

Only use vertex driven meshes for occlusion in the user's facial expression is needed to occlude correctly, otherwise, use bone driven or static meshes.

Download this example with all assets

Did this answer your question?