Develop

Layer and mesh rendering modes

Updated: Nov 20, 2026

Overview

Spatial SDK optimizes panels for most use cases by default. For specific effects, you’ll need deeper configuration.

Layers in 2D panels

Layers provide superior visuals but come with tradeoffs. The comparison below shows a panel with and without layers. The effect is much more noticeable in your Meta VR device.

Example of a panel not using layers

Screenshot of a panel that is blurry and not using layers

Example of a panel using layers

Screenshot of a panel that is not blurry and using layers
See Compositor layers for technical details.

Layers blending modes

When using layers, the blend type decides how the layer combines with the scene. Layer blending modes is the canonical guide, covering each mode, the panel settings and PanelConfigOptions forms, and troubleshooting. MASKED is the default for UIPanelSettings.
The images below show one texture whose corners have an alpha value of 0, rendered in each mode without feathering, which the next section explains. The images appear in table order: OPAQUE, MASKED, then ALPHA_BLEND.
ModeResult without feathering
OPAQUE
Every pixel renders and the alpha value is ignored, so the corners are solid
MASKED
Each sample either renders or does not, so the corners are cut out and the edges are aliased
ALPHA_BLEND
The corners fade smoothly. This mode does not write to the depth buffer, so alpha blended geometry can appear in the wrong order
Panel with OPAQUE blending mode showing corners rendered as solid despite zero alpha values
Panel with MASKED blending mode showing corners cut out with visible aliasing along edges
Panel with ALPHA_BLEND mode showing smooth transparency transition from opaque to transparent

Feathering

One limitation of the layer API is that black lines may be seen along the edges. The scene is rendered with coarser pixels than the layers, and this mismatch can cause a black edge to appear in those misaligned areas. Feathering was introduced to Spatial SDK to fix these areas. It shrinks the cutout by about 1.5 pixels to remove the black line. The effect varies based on the blending mode.

PanelShapeLayerBlendType.OPAQUE

OPAQUE mode with feathering showing soft edges while treating texture as opaque
In the OPAQUE mode, the edges of the panel are shrunk slightly with a soft feathered edge. However, the alpha value of the texture is ignored, and all texels are treated as opaque, except for the feathering on the borders.

PanelShapeLayerBlendType.MASKED

MASKED mode with feathering applied to reduce black line artifacts at edges
Masked treats the image as masked, but analyzes the alpha of the texture to remove the black lines. Note that since there is no actual blending (each pixel is either rendered or not) there can still be some black lines visible around the edges.

PanelShapeLayerBlendType.ALPHA_BLEND

ALPHA_BLEND with feathering providing highest quality smooth edge transitions
For the highest quality edges, use ALPHA_BLEND with feathering. In addition to feathering the edges, it will analyze the alpha of the interior of the texture and apply a smooth blend to the transition. This also provides increased quality for alpha blend edges.

Layers example

Panels can use layers (recommended for crisp, high-quality visuals) or mesh (simpler but lower quality) rendering. This applies to both UI panels and readable media panels.
Layers provide superior visual quality and are the default rendering mode. Enable layers by setting renderMode to PanelRenderMode.Layer() in your panel render options:
// UI panels with layers
UIPanelSettings(
    rendering = UIPanelRenderOptions(
        renderMode = PanelRenderMode.Layer() // Default - enables layers
    )
)

Using mesh rendering

For simpler panels where visual quality is less critical, use mesh rendering instead of layers:
// UI panels with mesh rendering
UIPanelSettings(
    rendering = UIPanelRenderOptions(
        renderMode = PanelRenderMode.Mesh() // Use mesh instead of layers
    )
)
Note: Mesh rendering is not recommended for panels with text or complex UI. They will appear low-resolution compared to layers.
Known issue:ReadableMediaPanelRenderOptions with PanelRenderMode.Mesh() incorrectly creates a compositor layer. See Known issues for details and workarounds.

Media panel rendering

  • VideoSurfacePanelRegistration: Uses direct-to-surface rendering, only available with layers
  • ReadableVideoSurfacePanelRegistration: Supports both layer and mesh rendering modes as shown above
See Configuring media playback for more details.

(Advanced) Using PanelConfigOptions for layer configuration

Advanced usage: This section is for developers who need direct control over layer configuration beyond what the Panel Settings APIs provide.
For legacy code or custom layer behavior, configure layers directly using PanelConfigOptions:
import com.meta.spatial.runtime.LayerConfig

PanelConfigOptions().apply {
    // Enable layers
    layerConfig = LayerConfig()

    // Or disable layers (use mesh rendering)
    layerConfig = null

    // Advanced layer configuration with hole punching
    layerConfig = LayerConfig(filters = LayerFilters.HIGHEST_QUALITY, zIndex = -1)
    layerBlendType = PanelShapeLayerBlendType.ALPHA_BLEND
    enableLayerFeatheredEdge = true
    alphaMode = AlphaMode.HOLE_PUNCH
    panelShader = SceneMaterial.HOLE_PUNCH_PANEL_SHADER
}
To avoid using layers, remove layerConfig from your configuration along with the panelShader and alphaMode changes.

Design guidelines