From 3a343f881175e1891b9b062fe17001cbb1e36f61 Mon Sep 17 00:00:00 2001 From: milan Date: Sun, 9 Oct 2022 17:06:21 +0200 Subject: [PATCH] optimisation: only render visible portals --- Assets/Escape Room Engine/Portal/Portal.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Escape Room Engine/Portal/Portal.cs b/Assets/Escape Room Engine/Portal/Portal.cs index 0d648b7..6a8ddcf 100644 --- a/Assets/Escape Room Engine/Portal/Portal.cs +++ b/Assets/Escape Room Engine/Portal/Portal.cs @@ -60,6 +60,12 @@ namespace Escape_Room_Engine.Portal private void Render(ScriptableRenderContext scriptableRenderContext, Camera camera) { + // check whether the portal plane is visible from the player camera + var frustumPlanes = GeometryUtility.CalculateFrustumPlanes(_playerCamera.camera); + if (!GeometryUtility.TestPlanesAABB(frustumPlanes, other.portalQuad.bounds)) + // don't render this portal if it is not visible + return; + var t = transform; foreach (var eye in Eyes)