# SceneCapture Projection Matrix for Portal

**URL:** <https://forums.unrealengine.com/t/scenecapture-projection-matrix-for-portal/470042>\
**Category:** C++\
**Tags:** portal, scenecapture2d, Scene-Capture, projection-matrix, unreal-engine, CPP, question\
**Created:** [August 20, 2020, 1:47am UTC](https://forums.unrealengine.com/t/scenecapture-projection-matrix-for-portal/470042 "2020-08-20T01:47:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orion31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Orion31](https://forums.unrealengine.com/u/Orion31)\
**Post date:** [August 20, 2020, 1:47am UTC](https://forums.unrealengine.com/t/scenecapture-projection-matrix-for-portal/470042/1 "2020-08-20T01:47:44Z")

</div>

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

 ![310770-k5rpvc6312i51.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/f/a1f85fc53143b443b208feeac2c173a3e8040914.png)

From Portal1, this cube is seen, despite being in front of the portal:

 ![310771-m5t7s8g612i51.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/b/4cb739f31ed27d941c857660ad84b77ae4de58f4.png)

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 [Creating Seamless Portals in Unreal Engine 4 | Froyok - Fabrice Piquet](https://www.froyok.fr/blog/2019-03-creating-seamless-portals-in-unreal-engine-4/))

After compiling, I saw this horrible monstracity:

 ![310772-px2rrzdx12i51.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/9/cd90ccec234ff1bfb39a2314698a54daba262661.png)

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!
