# How can I set vertical AND horizontal FoV independent from each other with a cine camera in C++?

**URL:** <https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [December 1, 2023, 2:49pm UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658 "2023-12-01T14:49:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SarahH05071](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SarahH05071](https://forums.unrealengine.com/u/SarahH05071)\
**Post date:** [December 1, 2023, 2:49pm UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/1 "2023-12-01T14:49:53Z")

</div>

I need this for implementing a sensor with abitrary vertical/horizontal FOV.

I tried to set Filmback.SensorWidth/Filmback.SensorHeight and the values are shown in the Editor, but only width is applied correctly in the visual output. If I try to set the second variable over Filmback.SensorAspectRatio that is overwritten.

---

<div class="post-metadata">

**Author:** ![SarahH05071](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SarahH05071](https://forums.unrealengine.com/u/SarahH05071)\
**Post date:** [December 4, 2023, 11:43am UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/2 "2023-12-04T11:43:39Z")

</div>

If I use  
PlayerCamera-\>SetConstraintAspectRatio(false);  
both the values will be changed. But what I want would be an image filling the whole choosen window size, which is distorted depending on the vertical/horizontal field of view.

---

<div class="post-metadata">

**Author:** ![SolidSk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/solidsk/32/1194513_2.png) [@SolidSk](https://forums.unrealengine.com/u/SolidSk)\
**Post date:** [December 5, 2023, 7:38pm UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/3 "2023-12-05T19:38:16Z")

</div>

Maybe this post can help:

[https://forums.unrealengine.com/t/manipulate-horizontal-fov-without-affecting-vertical-fov/621443](https://forums.unrealengine.com/t/manipulate-horizontal-fov-without-affecting-vertical-fov/621443)

> But what I want would be an image filling the whole choosen window size, which is distorted depending on the vertical/horizontal field of view.

Do you want screen size to resize your image?

Anyway, I had problems with the Camera’s FoV, that how I set my Camera:

```auto
SceneCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("SceneCamera"));
SceneCamera->bOverrideAspectRatioAxisConstraint = true;
SceneCamera->AspectRatioAxisConstraint = AspectRatio_MajorAxisFOV; // Important
SceneCamera->SetupAttachment(SceneSpringArm, USpringArmComponent::SocketName);

```

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [December 5, 2023, 8:13pm UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/4 "2023-12-05T20:13:10Z")

</div>

To get the image to stretch to fill the window, no matter what the window dimensions are, you will have to use a render target to render from the camera, and then map the rendered part of that render target as a texture onto the window using a simple GUI widget bound to the target.

---

<div class="post-metadata">

**Author:** ![SarahH05071](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SarahH05071](https://forums.unrealengine.com/u/SarahH05071)\
**Post date:** [December 13, 2023, 8:03am UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/5 "2023-12-13T08:03:19Z")

</div>

Found a solution that worked:

> [@Display with non-square pixels](https://forums.unrealengine.com/t/display-with-non-square-pixels/396767):
>
> I am trying to support device with non square pixels. Display has aspect 16:9, but resolution is 1920x540. Even aspect is 16:9, image is rendered in 32:9 aspect, because it keeps pixel aspect 1. Constrain aspect is not solution too, because it adds only black stripes and keep pixel aspect 1. Is there easy way to force pixel aspect different from 1?

> [@Howto modify the projection matrix](https://forums.unrealengine.com/t/howto-modify-the-projection-matrix/287457/72):
>
> Hi, Thanks a lot. I managed to get your example project up ad running and it works fine. However, when I can’t get the same result when I add the OffAxisGameViewportClient class to my game. There were no errors when I was trying to compile the class and I modified the build.cs file of my project to add the dependencies In the editor, I’ve added a camera to the level and made player 0 auto-possess that. My level blueprint is also identical to yours. I’ve also added a blank C++ game mode class a…

You can overwrite CalcSceneView to get non-square pixels.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [January 12, 2024, 8:03am UTC](https://forums.unrealengine.com/t/how-can-i-set-vertical-and-horizontal-fov-independent-from-each-other-with-a-cine-camera-in-c/1444658/6 "2024-01-12T08:03:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
