# How do I get the projection matrix?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751>\
**Category:** Rendering\
**Tags:** projection-matrix, unreal-engine, Shaders, shader, CPP, question\
**Created:** [October 29, 2019, 8:50pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751 "2019-10-29T20:50:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0aa0a50c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0aa0a50c](https://forums.unrealengine.com/u/anonymous_user_0aa0a50c)\
**Post date:** [October 29, 2019, 8:50pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751/1 "2019-10-29T20:50:20Z")

</div>

For a shader I have I need to pass in the view projection matrix. I know how to calculate the view matrix, just the inverse of the camera’s transform. I cannot figure out where the get the projection matrix though. Does anyone know how? I know in Unity it was just unity\_MatrixVP.

---

<div class="post-metadata">

**Author:** ![Rijke](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rijke](https://forums.unrealengine.com/u/Rijke)\
**Post date:** [October 31, 2019, 3:57pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751/2 "2019-10-31T15:57:39Z")

</div>

I think `View.ViewToClip` should hold the “Projection” matrix, and `View.WorldToView` should be the “View” matrix. Alternatively, if you need the combined “ViewProjection” matrix, you can used `View.WorldToClip`.

---

<div class="post-metadata">

**Author:** ![DarioGangi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dariogangi/32/1215012_2.png) [@DarioGangi](https://forums.unrealengine.com/u/DarioGangi)\
**Post date:** [March 12, 2023, 5:23pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751/3 "2023-03-12T17:23:55Z")

</div>

Maybe in this way:

```auto
				auto* ViewportClient = GetWorld()->GetGameViewport();
				FSceneViewProjectionData ProjectionData;
				UGameplayStatics::GetPlayerController(this, 0)->GetLocalPlayer()->GetProjectionData(ViewportClient->Viewport, eSSP_FULL, /*out*/ ProjectionData);
				const auto& ProjectionMatrix = ProjectionData.ProjectionMatrix;

```

---

<div class="post-metadata">

**Author:** ![Mad.King](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mad.king/32/761302_2.png) [@Mad.King](https://forums.unrealengine.com/u/Mad.King)\
**Post date:** [August 9, 2025, 9:52am UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751/4 "2025-08-09T09:52:37Z")

</div>

you’re giving a c++ answer to an hlsl question. i.e. it’s not relevant i’m afraid

---

<div class="post-metadata">

**Author:** ![DarioGangi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dariogangi/32/1215012_2.png) [@DarioGangi](https://forums.unrealengine.com/u/DarioGangi)\
**Post date:** [September 7, 2025, 9:13pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-projection-matrix/457751/5 "2025-09-07T21:13:14Z")

</div>

You can pass the projection matrix to your material and use it by HLSL code.
