render stencil portals (stereo)
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using EscapeRoomEngine.VR.Runtime;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -87,12 +88,28 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public Camera SetUpCamera(Camera playerCamera)
|
||||
public Camera SetUpCamera(Camera playerCamera, Camera.MonoOrStereoscopicEye monoOrEye)
|
||||
{
|
||||
// place camera
|
||||
var m = portalTransform.localToWorldMatrix * HalfRotation *
|
||||
linkedPortal.portalTransform.worldToLocalMatrix * playerCamera.transform.localToWorldMatrix;
|
||||
playerCamera.transform.SetPositionAndRotation(m.GetPosition(), m.rotation);
|
||||
Matrix4x4 cameraTransform;
|
||||
if (monoOrEye == Camera.MonoOrStereoscopicEye.Mono)
|
||||
{
|
||||
cameraTransform = portalTransform.localToWorldMatrix * HalfRotation *
|
||||
linkedPortal.portalTransform.worldToLocalMatrix *
|
||||
playerCamera.transform.localToWorldMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
// stereoRenderCounter = (stereoRenderCounter + 1) % 2;
|
||||
var eye = monoOrEye == Camera.MonoOrStereoscopicEye.Left
|
||||
? Camera.StereoscopicEye.Left
|
||||
: Camera.StereoscopicEye.Right;
|
||||
cameraTransform = portalTransform.localToWorldMatrix * HalfRotation *
|
||||
linkedPortal.portalTransform.worldToLocalMatrix *
|
||||
Player.Instance.GetEye(eye).localToWorldMatrix;
|
||||
playerCamera.projectionMatrix = playerCamera.GetStereoProjectionMatrix(eye);
|
||||
}
|
||||
playerCamera.transform.SetPositionAndRotation(cameraTransform.GetPosition(), cameraTransform.rotation);
|
||||
|
||||
// set camera clip plane to portal (otherwise the wall behind the portal would be rendered)
|
||||
// calculating the clip plane: https://computergraphics.stackexchange.com/a/1506
|
||||
|
||||
Reference in New Issue
Block a user