Download

SceneCapture Projection Matrix for Portal

Hi,

I am new to Unreal and GameDev in general, but I was playing around and trying to make portals for fun. I noticed that when objects were placed in front of the portal, they can get in the way of the projection captured by the SceneCaptureComponent.

Here is the problem:

An extra cube is placed in front of Portal2
https://preview.redd.it/k5rpvc6312i51.png?width=1170
From Portal1, this cube is seen, despite being in front of the portal:
https://preview.redd.it/m5t7s8g612i51.png?width=824
While trying to fix this, I came across FClipProjectionMatrix and wrote these lines of code:


SceneCapture->ClipPlaneNormal = GetActorForwardVector();
SceneCapture->ClipPlaneBase = GetActorLocation();
SceneCapture->CustomProjectionMatrix = FClipProjectionMatrix(TargetPortal->GetCameraProjectionMatrix(), FPlane(GetActorLocation()));

(GetCameraProjectionMatrix() is from https://www.froyok.fr/blog/2019-03-c…real-engine-4/)

After compiling, I saw this horrible monstracity:
https://preview.redd.it/px2rrzdx12i51.png?width=1176
Technically the cube is gone, but now it looks awful. How could I fix this? I’m not really familiar with Matrices and Vectors (I’m only a HS Sophomore), but I’m trying to learn. Any help is appreciated!