# SceneCaptureComponent2D Custom Projection Matrix 4.17

**URL:** <https://forums.unrealengine.com/t/scenecapturecomponent2d-custom-projection-matrix-4-17/406364>\
**Category:** Rendering\
**Tags:** scenecapturecomponen, projection-matrix, unreal-engine, Rendering, UE4, CPP, question\
**Created:** [October 6, 2017, 8:01pm UTC](https://forums.unrealengine.com/t/scenecapturecomponent2d-custom-projection-matrix-4-17/406364 "2017-10-06T20:01:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_10da89e9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10da89e9](https://forums.unrealengine.com/u/anonymous_user_10da89e9)\
**Post date:** [October 6, 2017, 8:01pm UTC](https://forums.unrealengine.com/t/scenecapturecomponent2d-custom-projection-matrix-4-17/406364/1 "2017-10-06T20:01:31Z")

</div>

Hi,

SceneCaptureComponent2D.h contains the following

```
    /** Whether a custom projection matrix will be used during rendering. */
	UPROPERTY(BlueprintReadWrite, AdvancedDisplay, Category = Projection)
	bool bUseCustomProjectionMatrix;

	/** The custom projection matrix to use */
	UPROPERTY(BlueprintReadWrite, AdvancedDisplay, Category = Projection)
	FMatrix CustomProjectionMatrix;

```

I have tried deriving from SceneCaptureComponent2D to set a custom Matrix

```
#include "ARSceneCaptureComponent2D.h"

void UARSceneCaptureComponent2D::BeginPlay()
{
	bUseCustomProjectionMatrix = true;
	CustomProjectionMatrix = GenerateOffCenterMatrix(0.0F, 2000.0F, width, 
    height, skew, u0, v0, fx, fy);
}

FMatrix UARSceneCaptureComponent2D::GenerateOffCenterMatrix(float near, float far, float width, float height, float s, float u0, float v0, float fx, float fy)
{
	FMatrix out;
	float mat00 = 2.0F * fx / width;
	float mat11 = 2.0F * fy / height;
	float mat02 = (width - 2.0F * u0) / width;
	float mat12 = (-height + 2.0F * v0) / height;
	float mat22 = -(far + near) / (far - near);
	float mat23 = -(2.0F * far * near) / (far - near);
	float mat32 = -1.0F;
	// Setting perspective transformation Matrix
	out.SetIdentity();
	out.M[0][0] = mat00;
	out.M[0][1] = 0;
	out.M[0][2] = mat02;
	out.M[0][3] = 0;
	out.M[1][0] = 0;
	out.M[1][1] = mat11;
	out.M[1][2] = mat12;
	out.M[1][3] = 0;
	out.M[2][0] = 0;
	out.M[2][1] = 0;
	out.M[2][2] = mat22;
	out.M[2][3] = mat23;
	out.M[3][0] = 0;
	out.M[3][1] = 0;
	out.M[3][2] = mat32;
	out.M[3][3] = 0;
	return out;
}

```

Sadly my code won’t work, the image looks exactly the same with or without setting it. Has anyone tried this before and can tell me how to fix this?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0b6aef4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0b6aef4a](https://forums.unrealengine.com/u/anonymous_user_0b6aef4a)\
**Post date:** [August 7, 2018, 8:49am UTC](https://forums.unrealengine.com/t/scenecapturecomponent2d-custom-projection-matrix-4-17/406364/2 "2018-08-07T08:49:44Z")

</div>

You need to set bUseCustomProjectionMatrix to true to use your custom projection matrix.
