Skip to content

Performance and Optimization

aurycat edited this page Dec 27, 2025 · 2 revisions

Portal rendering is approximately as expensive as rendering a VRC Mirror. Every frame, the portal needs to render the entire scene again (twice, for each eye in VR), which means re-rendering the world & avatars!

To maximize performance, you should make sure to only have the portal active when the local player could possibly see it. Both portals in a pair do NOT need to be active at once, unless the player could actually see both portals at once.

One way to activate the portal on demand is with a trigger collider script which turns the portal on when the local player enters it, and turns the portal off when they leave it. Here is some example U# code to do that:

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class PortalEnabler : UdonSharpBehaviour
{
	public GameObject portal;

	public override void OnPlayerTriggerEnter(VRCPlayerApi player)
	{
		if (Utilities.IsValid(player) && player.isLocal) {
			portal.SetActive(true);
		}
	}

	public override void OnPlayerTriggerExit(VRCPlayerApi player)
	{
		if (Utilities.IsValid(player) && player.isLocal) {
			portal.SetActive(false);
		}
	}
}

Then, add a trigger Box Collider on the same object as that script which covers the area near the portal.

Clone this wiki locally