---
title: PortalMaterial
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/portalmaterial
---

# PortalMaterial

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

## Declaration

```swift
struct PortalMaterial
```

## Overview

Overview You use a PortalMaterial with PortalComponent and 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:). It can have some faces using PhysicallyBasedMaterial and some faces using PortalMaterial. 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])) ))

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 for example usage.

## Topics

### Specifying the shader program

- [program](realitykit/portalmaterial/program-swift.property.md)
- [PortalMaterial.Program](realitykit/portalmaterial/program-swift.struct.md)

### Accessing shader parameters

- [getParameter(name:)](realitykit/portalmaterial/getparameter(name:).md)
- [getParameter(handle:)](realitykit/portalmaterial/getparameter(handle:).md)
- [setParameter(name:value:)](realitykit/portalmaterial/setparameter(name:value:).md)
- [setParameter(handle:value:)](realitykit/portalmaterial/setparameter(handle:value:).md)
- [parameterHandle(name:)](realitykit/portalmaterial/parameterhandle(name:).md)

### Initializers

- [init()](realitykit/portalmaterial/init().md)
- [init(program:)](realitykit/portalmaterial/init(program:).md)

### Instance Properties

- [faceCulling](realitykit/portalmaterial/faceculling-swift.property.md)
- [triangleFillMode](realitykit/portalmaterial/trianglefillmode-swift.property.md)

### Type Aliases

- [PortalMaterial.FaceCulling](realitykit/portalmaterial/faceculling-swift.typealias.md)
- [PortalMaterial.TriangleFillMode](realitykit/portalmaterial/trianglefillmode-swift.typealias.md)

## Relationships

### Conforms To

- [Material](realitykit/material.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Portals

- [PortalMaterial.FaceCulling](realitykit/portalmaterial/faceculling-swift.typealias.md)
- [PortalMaterial.TriangleFillMode](realitykit/portalmaterial/trianglefillmode-swift.typealias.md)
- [PortalComponent](realitykit/portalcomponent.md)
- [WorldComponent](realitykit/worldcomponent.md)
- [PortalCrossingComponent](realitykit/portalcrossingcomponent.md)
