<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PortalMaterial",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14PortalMaterialV"
  },
  "title" : "PortalMaterial"
}
-->

# PortalMaterial

A material that makes the mesh part a portal to a different world.

```
struct PortalMaterial
```

## Overview

You use a `PortalMaterial` with [`PortalComponent`](/documentation/RealityKit/PortalComponent) and [`WorldComponent`](/documentation/RealityKit/WorldComponent) to enable portal features.

You can set this material on individual mesh parts. For example, create a box with
[`generateBox(width:height:depth:cornerRadius:splitFaces:)`](/documentation/RealityKit/MeshResource/generateBox(width:height:depth:cornerRadius:splitFaces:)).
It can have some faces using [`PhysicallyBasedMaterial`](/documentation/RealityKit/PhysicallyBasedMaterial) and some faces using `PortalMaterial`.

```swift
let portal = Entity()
// When you set `splitFaces` to `true`, each face takes up a different material slot.
let cyanMaterial = SimpleMaterial(color: .cyan, isMetallic: false)
portal.components.set(ModelComponent(
    mesh: .generateBox(width: 0.5, height: 0.5, depth: 0.5, splitFaces: true),
    materials: [PortalMaterial(),
                cyanMaterial,
                cyanMaterial,
                cyanMaterial,
                cyanMaterial,
                cyanMaterial]
))
// Because the box has `0.5 x 0.5 x 0.5` dimensions,
// offset the portal plane on the z-axis by 0.25 so that
// it's at the front of the cube.
// Make sure it faces toward the positive z-direction.
portal.components.set(PortalComponent(
    target: world,
    clippingMode: .disabled,
    crossingMode: .plane(PortalComponent.Plane(position: [0, 0, 0.25], normal: [0, 0, 1]))
))
```

![A screenshot of cyan color box with only one face using portal material and a spaceship poking out of it](images/com.apple.RealityKit/portal-material-box.png)

RealityKit treats each mesh part with a `PortalMaterial` as a different portal, even if they
are pointing to the same world. Beware of the performance impact of this usage.

See [`PortalComponent`](/documentation/RealityKit/PortalComponent) for example usage.

## Topics

### Specifying the shader program

[`program`](/documentation/RealityKit/PortalMaterial/program-swift.property)

The compiled program that drives this material’s surface and geometry shading.

[`Program`](/documentation/RealityKit/PortalMaterial/Program-swift.struct)

A compiled shader program that drives the appearance of a portal’s surface and geometry.

### Accessing shader parameters

[`getParameter(name:)`](/documentation/RealityKit/PortalMaterial/getParameter(name:))

Returns the value of a parameter by name.

[`getParameter(handle:)`](/documentation/RealityKit/PortalMaterial/getParameter(handle:))

Returns the value of a parameter identified by a handle.

[`setParameter(name:value:)`](/documentation/RealityKit/PortalMaterial/setParameter(name:value:))

Sets the value of a parameter by name.

[`setParameter(handle:value:)`](/documentation/RealityKit/PortalMaterial/setParameter(handle:value:))

Sets the value of a parameter identified by a handle.

[`parameterHandle(name:)`](/documentation/RealityKit/PortalMaterial/parameterHandle(name:))

Returns a handle for the parameter with the given name.

## Relationships

### Conforms To

[`Material`](/documentation/RealityKit/Material)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)