Table of Contents

Using EasyAR Mega for occlusion in unity

Occlusion is a key technology for enhancing the immersion of AR virtual-real fusion. This article will introduce how to achieve occlusion effects in Unity using EasyAR Mega.

Before you begin

Occlusion implementation methods

  • Offline modeling: In the Block coordinate system, create 1:1 matched geometric bodies for physical objects in the real world (such as walls, columns, large equipment); or obtain optimized models by cropping and reducing faces of the Block dense model.

  • Runtime alignment: At runtime, align the Block coordinate system with the physical space through cloud localization, and load corresponding geometric bodies.

  • Material replacement: Assign special occlusion materials to these geometric bodies.

  • Visual effect: When the GPU renders other virtual objects, pixels in occluded areas will be automatically culled due to failed depth testing, making virtual objects follow real-world occlusion logic.

How to use geometric bodies as occlusion

Follow these steps to add geometric bodies as occlusion in the scene and verify the effect.

Place occlusion geometric bodies

Place built-in or self-created geometric bodies as occlusion at correct positions in the Block coordinate system based on the Mega Block dense model. Place occlusion geometric bodies

[Optional] Fine-tune geometric body positions based on panoramic images

Fine-tune occlusion based on panoramic images

Assign occlusion materials to geometric bodies

Modify the geometric body material to occlusion material, such as Unity's built-in SpatialMappingOcculusion. Fine-tune occlusion based on panoramic images

Simulate operation with EIF data or run on device

Fine-tune the placement of occlusion models based on runtime effects.

How to use cropped and face-reduced dense models as occlusion

Follow these steps to export the Mega Block dense model, crop and reduce faces to obtain a white model for occlusion, and import it into the scene as occlusion.

Export in Mega Blocks

Select export in the Inspector panel's Mega Blocks tool

Select export

Modify export options

Modify export options during export.

Export options

1 in the figure is the LOD level. Lower levels mean simpler models with fewer faces. Choose 2 for highest precision, or 1/0 for reduced precision with fewer faces.

2 in the figure is the texture export option. Since we only need a white model for occlusion, textures are unnecessary.

Crop and reduce faces of the model

Crop and reduce faces of the exported model in digital content creation software (e.g. Blender), then save as Glb.

Tip

The example uses Blender's Decimate Modifier.

Before cropping

After cropping and face reduction:

After cropping

Import the occlusion model into Unity and mount it under the Block node in the scene

Import occlusion model

Modify the model's Transform

Modify the model's Transform so that Position and Rotation are all set to 0.

The white occlusion model should now align with the dense model, because cropping and face reduction in digital content creation software doesn't alter the Block coordinate system definition.

Occlusion model alignment

Assign occlusion materials to the model

Change the model material to occlusion material, such as Unity's built-in SpatialMappingOcculusion.

Change occlusion model material

Simulate operation with EIF data or run on device

Simulate operation with EIF data or run on device to view the effect.

Expected occlusion effect

The occlusion effect is mainly influenced by:

  • Accuracy of localization and tracking itself
  • Precision of model placement
  • Model's own precision (if not simple geometric bodies)

Misalignment of several centimeters during localization drift is normal.

High face count in occlusion models may impact performance. It's recommended to use them only in necessary areas and prefer simple geometric bodies for occlusion.