Masking allows control of where the effect appears on screen. The primary use is to exclude certain objects from the effect (see MASK Mode), but it can also be used to provide areas of the effect which appear regardless of motion. These areas can be relative to the user (see WINDOW Mode) or in world-space (see PORTAL Mode).
TIP: WINDOW mode creates the effect described in this Oculus blog post under the heading Window Into the Moving World, while PORTAL mode creates the effect under the heading Portals Into the Static World.
To ignore transparent and UI elements, consider using TunnellingOpaque instead of Tunnelling - this draws the effect after opaque geometry rather than at the end of the frame. See the manual home page for more details.
TIP: All Mask Modes can be used with all Background Modes - for example, MASK with BLUR will blur everything in the periphery except masked objects.
Regardless of Mask Mode there are two ways to mask an object.
The simplest is to add a TunnellingMaskObject script[API] to any object to be masked. The object must have a Renderer component, such as a MeshRenderer. Ticking Auto Add Children will include child Renderer objects in the mask. Disabling the component or the gameobject will stop it being masked, and re-enabling will again add it to the mask.
Objects can also be masked from code using the AddObjectToMask (Renderer r, bool includeChildren) and RemoveObjectFromMask (Renderer r, bool includeChildren) methods. Alternatively, just use gameObject.AddComponent<TunnellingMaskObject>()
.
TIP: All Mask Modes except OFF will disable the Iris Z Rejection optimisation (see Background Modes).
TIP: The mobile version cannot use WINDOW or PORTAL modes. Please see the mobile manual page for details.