This page concerns the Vuforia Engine API version 9.8 and earlier. It has been deprecated and will no longer be actively updated.
An occlusion model enables you to mask the surfaces of a physical object so that virtual objects are not rendered over them when they are behind the object in your scene. This effect relies on depth masking and provides a much more realistic rendering for scenes that combine physical and virtual objects.
Depth masking via an occlusion model is accomplished by developing a 3D model or mesh of the regions of the object that you want to mask and then apply a depth mask shader to that model. The depth mask will prevent any objects behind the masked region from being rendered.
Occlusion Management
A volumetric occlusion model
An occlusion model can match the exact geometry of the physical object that it corresponds to, or it can be a simplified representation of the object, such as its bounding box. The latter technique is an easy way to occlude physical objects with simple geometries, like boxes, balls and cylinders and ideal for Multi Targets and Cylinder Targets.
A geometrically accurate occlusion model
For Model Targets and Object Targets, it is recommended to use a geometrically accurate occlusion model. And, it is best if you only use the exterior surfaces of the model, at the lowest polygon count needed to provide satisfactory masking of your physical object. You can use a 3D modeling editor to simplify your model by reducing the polygon count and removing any duplicated or hidden (e.g. internal) geometries.
TIP: If you use an occlusion model as well as render virtual augmentations that are closely aligned to the surface of the physical object, be sure to test the rendering results on the device platforms that you intend to deploy to. When 3D models are closely aligned, they can become confused in the renderer's depth buffer. This is an problem known as Z-Fighting ( Z is for Z Axis ) and can result in noisy rendering artifacts. To avoid Z-Fighting, use the MODE_OPTIMIZE_QUALITY setting on the ARCamera and offset your models so that they are not overlapping each other.
How to Configure a Model to Occlude for a Physical Object
- Import your occlusion model to your Unity project or create a simple bounding model by selecting a primitive mesh geometry from Game Object -> Create Other in the Editor menu.
- Drag the model onto your Vuforia Target instance in the Hierarchy so that it is a child of the Vuforia Target instance, in this case an ObjectTarget.
- Carefully align the position of your occlusion model in relation to its corresponding target.
- Add a Depth Mask Shader to your occlusion model’s material or add the Unity built-in SpatialMappingOcclusion material to your model’s mesh in order for it be hidden during runtime.
- Add your augmentable content to your scene to test that your occlusion model is masking the physical object accurately.
- Start Vuforia Play Mode to evaluate the occlusion effect in the scene.
- Verify the accuracy of your occlusion model registration from multiple positions in the scene.
Related Topics
Introduction to Model Targets in Unity