In the UE4 SteamVR integration, HMD resolution is set with r.screenpercentage. This is baselined off of the mirror window’s resolution, and this seems error prone.
At startup, the UE4 SteamVR integration will pick a screenpercentage based on the results of OpenVR’s GetRecommendedRenderTargetSize call.
// determine our ideal screen percentage
uint32 RecommendedWidth, RecommendedHeight;
VRSystem->GetRecommendedRenderTargetSize(&RecommendedWidth, &RecommendedHeight);
RecommendedWidth *= 2;
int32 ScreenX, ScreenY;
uint32 ScreenWidth, ScreenHeight;
GetWindowBounds(&ScreenX, &ScreenY, &ScreenWidth, &ScreenHeight);
float WidthPercentage = ((float)RecommendedWidth / (float)ScreenWidth) * 100.0f;
float HeightPercentage = ((float)RecommendedHeight / (float)ScreenHeight) * 100.0f;
float ScreenPercentage = FMath::Max(WidthPercentage, HeightPercentage);
//@todo steamvr: move out of here
static IConsoleVariable* CScrPercVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.ScreenPercentage"));
if (FMath::RoundToInt(CScrPercVar->GetFloat()) != FMath::RoundToInt(ScreenPercentage))
{
CScrPercVar->Set(ScreenPercentage);
}
This seems fine, but the problem is if the mirror window ever changes afterwards, the screenpercentage begins being baselined off of the wrong resolution (some games have resizable mirrors).
It seems like for VR, r.screenpercentage itself should be baselined off of either the native HMD resolution or the result of GetRecommendedRenderTargetSize directly, and not be tied back to the resolution of the mirror window in any way, since it is just a detached mirror, unrelated at all to the HMD resolution. This has thrown off several developers.