render stencil portals (stereo)

This commit is contained in:
2023-03-15 13:47:11 +01:00
parent 52fa079fce
commit c024ddfe5e
11 changed files with 578 additions and 643 deletions

View File

@@ -16,9 +16,9 @@ namespace EscapeRoomEngine.Portal.Runtime
private class PortalCameraRenderPass : ScriptableRenderPass
{
private static readonly List<ShaderTagId> ShaderTagIds = new List<ShaderTagId>
private static readonly List<ShaderTagId> ShaderTagIds = new()
{
new("SRPDefaultUnlit"), new("UniversalForward"), new("UniversalForwardOnly")
new ShaderTagId("SRPDefaultUnlit"), new ShaderTagId("UniversalForward"), new ShaderTagId("UniversalForwardOnly")
};
private RenderStateBlock _renderStateBlock;
@@ -74,8 +74,15 @@ namespace EscapeRoomEngine.Portal.Runtime
var originalPosition = cameraTransform.position;
var originalRotation = cameraTransform.rotation;
var originalProjection = camera.projectionMatrix;
camera = linkedPortal.SetUpCamera(camera);
RenderingUtils.SetViewAndProjectionMatrices(_commandBuffer, camera.worldToCameraMatrix, GL.GetGPUProjectionMatrix(camera.projectionMatrix, true), false);
camera = linkedPortal.SetUpCamera(camera,
camera.stereoEnabled
? cameraData.xr.multipassId == 0
? Camera.MonoOrStereoscopicEye.Left
: Camera.MonoOrStereoscopicEye.Right
: Camera.MonoOrStereoscopicEye.Mono);
RenderingUtils.SetViewAndProjectionMatrices(_commandBuffer,
camera.worldToCameraMatrix,
GL.GetGPUProjectionMatrix(camera.projectionMatrix, true), false);
// execute command buffer
context.ExecuteCommandBuffer(_commandBuffer);