Handle viewport aspect ratio not matching viewport dimensions. #708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.