Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle viewport aspect ratio not matching viewport dimensions. #708

Merged
merged 2 commits into from Jan 3, 2022

Conversation

kring
Copy link
Member

@kring kring commented Dec 16, 2021

This fixes part of #680.

If an Editor viewport is viewing a particular camera, and that camera specifies an aspect ratio that doesn't match the dimensions of the viewport window, Unreal draws black bars at the sides or at the top and bottom, i.e. letterboxing. No real surprise there, of course.

image

The perhaps more surprising thing is that FEditorViewportClient::GetViewportDimensions returns the size of the complete window, not the size of the portion in which rendering occurs. That is, the black bars are included in the size.

Having not realized or appreciated this, we were using the window dimensions for LOD computations, and computing the vertical FOV from the aspect ratio implied by the window dimensions. This caused LOD and culling problems, as seen in #680.

So with this PR, we use the actual aspect ratio, and compute the dimensions of the rendered area.

This PR also has a change to get the viewport size from the player controller in-game, rather than the world's game viewport. I don't know of a situation where this will make a difference, but it should be more correct.

Unfortunately this doesn't fix #680. Even with this change, when we're using the Movie Render Queue specifically, the player controller's GetViewportSize always returns 1920x1080 even when a different size has been specified. I spent hours trying to figure out how to get the actual size, but haven't figured it out yet. I wrote a UDN ticket to ask Epic:
https://udn.unrealengine.com/s/question/0D54z00007LQvtdCAD/how-to-get-the-viewport-size-when-using-the-movie-render-queue

So this PR should be a good change worth merging, but some additional work will likely be necessary when we hear back from Epic.

@cesium-concierge
Copy link

Thanks for the pull request @kring!

  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

@nithinp7 nithinp7 merged commit d6664fa into main Jan 3, 2022
@nithinp7 nithinp7 deleted the aspect-ratio branch January 3, 2022 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frustrum culling does not account for different aspect ratios (In Sequencer)
3 participants