How to ensure desired fov / ratio is preserved

Hi,

We have two use case examples:

  • We are targeting display system which are expected very specific fields of view, both horizontal and vertical regardless of the actual screen resolution.
  • We are displaying simulated sensor view and the sensor hardware has a given resolution.

We do not want to be restricted to actual window with the exact same ratio / resolution.

How can we request Unreal Engine *not* to recompute field of views to align with the window (and without adding the black bands) ?

Thanks,

Steps to Reproduce

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into this control for the FoV and resolution for you.

Hi Stephen,

Good to hear.

Looking forward to your inputs.

Hello,

Since you want to decouple the renders you are making from the window, can you render using a Scene Capture Component, to a render target of the desired resolution? You can set the desired FOV on the Scene Capture Component. This render target can then be displayed on the main window via UI elements or similar.

If you don’t need to display the captured output, the render target can be used similar to a texture in Materials as needed.

Please let us know if this helps.

Hi Stephen,

I did not want to orient the answer but, so far, we came up with two workarounds:

  • Using a scene capture with desired resolution, in that case, we can inder render with the desired render target resolution. We are yet to double check that the actual expected hfov / vfov ratio in indeed preserved.
  • Using a customized viewport with an override from the “virtual float GetDesiredAspectRatio () const override” method.

Both options have drawbacks and feel wrong.

If we have a unique view and require a render target, then we need an extra rendering we were not able to disable impacting performance for no reason.

If we use a modified viewport, the ratio override cannot be applied to multiple views.

It does fill we are missing something. In particular, why is there no option in this enum for preserving user desired values :

https://dev.epicgames.com/documentation/en\-us/unreal\-engine/API/Runtime/Engine/EAspectRatioAxisConstraint

More links are exploring solutions but none seem fine:

Hi Stephen,

Here are some answers / background information:

Based on your query, it seemed like you were trying to render two views since you mentioned not being restricted to actual window. But with your update, it seems at any given time you only render through one view. Is this correct?

--> We are building a COTS product / plugins which is loading a configuration file (or receives external trigger) regarding desired view settings. The most common use case are :

  • A single full screen view with very accurate field of view.
  • A dual view with a global view and an integrated smaller vignette using picture in picture.

To prevent the black bars you can try disabling bConstraintAspectRatio on the Camera Component.

--> We tried this but the FOV gets scaled to adapt screen ratio and we do not want this.

By default, as you have noticed the FOV does constrain itself based on the axis constraint picked. To change this you can try using a SceneViewExtension to modify the projection matrix to what you need. The constructor for FReversedZPerspectiveMatrix does provide a version that takes an explicit value for both Horizontal and Vertical if that is desired.

--> This seems fine. However, when we looked into scene view extension, we were not able to find everything we needed. I suspect you are referring to this method :

/**

* Called when creating the view, in case non-stereo devices need to update projection matrix.

*/

virtual void SetupViewProjectionMatrix(FSceneViewProjectionData& InOutProjectionData) {}

The scene projection data did not allow us to retrieve easily the actual view that is being rendered. Lacking an index / identifier of some sort. Looking into it again, I wonder if we could be using the viewport (constrained / unconstrained rectangles) to backtrace our internal view.

Is this what you were suggesting or is there anything we are missing ?

Hi Stephen,

We are building a product which should not rely on engine modification for various reasons.

While extending the structure to propagate some identification elements seems the nicest solution, it is not one we can pursue.

I guess / fear you confirmed all our findings and understanding. I will review this with the team but I doubt there is more inputs you can provide on this matter.

Thanks,

Basile

To help us better solve this issue for you, can you please answer these questions about your desired result?

Based on your query, it seemed like you were trying to render two views since you mentioned not being restricted to actual window. But with your update, it seems at any given time you only render through one view. Is this correct?

To prevent the black bars you can try disabling bConstraintAspectRatio on the Camera Component.

By default, as you have noticed the FOV does constrain itself based on the axis constraint picked. To change this you can try using a SceneViewExtension to modify the projection matrix to what you need. The constructor for FReversedZPerspectiveMatrix does provide a version that takes an explicit value for both Horizontal and Vertical if that is desired.

Hello,

Disabling bConstrainAspectRatio is intended to work with the Scene View Extension, to allow you to lock both aspect ratios.

The function you are looking at in the Scene View Extension is correct, for modifying the projection matrix.

Scene View Extensions have another function “IsActiveThisFrame(…)” that controls if the other functionality of the SceneViewExtension.

If you need more information in “SetupViewProjectionMatrix(…)”, you can look into engine modifications to add a parameter of the type “FMinimalViewInfo”. As a starting point, please see where this function is called in “ULocalPlayer::GetProjectionData(…)”

For engine modifications like this, we can offer information about existing functionality, and we leave the details of the implementation to you.

Please let us know if this helps.

Hello,

Thank you for the reply.

If you have any other questions, please let us know. If not, can we close this ticket?