/// <summary> /// Render a Portal frame, assuming that the camera is in front of the Portal and all conditions are met. /// </summary> /// <param name="camera">The camera rendering the Portal</param> /// <param name="nearClipVerts">The vertices of the camera's near clip plane</param> private void TryRenderPortal(Camera camera, Vector3[] nearClipVerts) { if (!TargetPortal) { return; } //bool isVisible = false; bool isVisible = false; //Check if the camera itself is behind the Portal, even if the frustum isn't. if (!PortalUtils.IsBehind(camera.gameObject.transform.position, Origin.position, Origin.forward)) { isVisible = true; } else { //Checks to see if any part of the camera is in front of the Portal foreach (Vector3 v in nearClipVerts) { if (!PortalUtils.IsBehind(v, Origin.position, Origin.forward)) { isVisible = true; break; } } } if ((isVisible || _cheeseActivated != -1)) { PortalCamera.RenderIntoMaterial(camera, PortalMaterial, MeshRenderer, TargetPortal.MeshRenderer, MeshFilter.mesh, !NonObliqueOverride ? _cheeseActivated == -1 : false, Is3D); } }
private void OnWillRenderObject() { if (GameMaster.Instance.IsAnotherWorld() == isSub) { portalCamera.RenderIntoMaterial(_portalMaterial); } }