December 19, 2017

Significant Changes Coming To VR Resolution Settings in 4.19

By Sam Deiter

In the upcoming 4.19 release of Unreal Engine(UE4), the cvar used to set the resolution at which your UE4 Virtual Reality(VR) project will be rendered has been changed. While this new change streamlines adjusting the resolution of your VR project across all of the VR platforms UE4 supports, it will, unfortunately, break backward compatibility with all previous UE4 VR projects. Here’s how this will affect your VR projects and what you can do to fix any performance regressions that this change will cause when upgrading to 4.19.

Determining HMD Resolution in 4.18 and Previous Versions

In previous versions of UE4, the Screen Percentage cvar (r.ScreenPercentage) was used to determine the resolution that the engine should render your VR project at for a given HMD screen. While this was a valid way to control the resolution of your VR project it took some guesswork to figure out which number you needed to use as each HMD required a different Screen Percentage amount. The reason for this is because the r.ScreenPercentage cvar was controlling the rendering resolution using a percentage according to the display panel resolution and not the ideal resolution for the HMD. For more information on why we chose this method, see this presentation from VR and AR Technical Director Nick Whiting.

Since each supported HMD has a slightly different panel resolution and distortion function, settings for r.ScreenPercentage would need to vary device by device. This means that while one value would work for one HMD, the same value used on other HMDs would not look as good.

Setting HMD Resolution in 4.19 and Beyond

To make things easier, we’ve added a new cvar to 4.19 called vr.PixelDensity that can be controlled with a normalized value where 1 is the ideal resolution for the HMD that is currently being used. Lower values will perform faster but will be undersampled (more blurry) while values over 1 will perform slower and will supersample (extra sharp). Going forward, you should always use vr.PixelDensity to adjust the resolution given to the HMD compositor for your VR project and always set your r.ScreenPercentage to 100. The following table shows examples of what the previous r.ScreenPercentage values to run the various HMD at it's ideal resolution would be when converted into the new vr.PixelDensity cvar.
VRBlogScreenPerToVRPixel_1.jpg

PixelDensity_Chart.PNG

Notice that all the HMDs have their vr.PixelDensity value set to a value of 1, telling each HMD to run at its ideal resolution. Another added benefit to using vr.PixelDensity is that you can also easily increase or decrease the resolution of your VR project using values that make logical sense.

Number of pixel drawn = 2 x HMDs ideal width x HMDs ideal height x (vr.PixelDensity)²

For example, if you wanted to reduce the number of pixels to render of your VR project by about 20% you would set vr.PixelDensity=sqrt(1-0.2). If you wanted to increase the number of pixels to render of your VR project by about 20%, you would input vr.PixelDensity=sqrt(1+0.2).

Moving from r.ScreenPercentage to vr.PixelDensity

If you have developed any code that adjusts the r.ScreenPercentage cvar, make sure that it instead uses vr.PixelDensity and that the r.ScreenPercentage cvar is set back to its default value of 100 to avoid any potential performance issues when upgrading to 4.19 or subsequent versions. Failing to replace any reference to the r.ScreenPercentage cvar with the vr.PixelDensity cvar will result in a severe performance drop in your project since you could end up rendering more pixels than needed (and nobody wants that!)

When making this change, keep in mind that defaulted vr.PixelDensity=1 specifies a resolution that is larger than 4.18's r.ScreenPercentage=100, so make sure to do extensive performance testing. Below you will find a few examples of the various ways to make this change in your UE4 projects.

Blueprint Setup:

VRPixelDensity_BP_Commandline.jpg

INI Setup:

VRPixelDensity_DefaultEngine.jpg

Have questions about the change? Let us know on the forums

Make something Unreal

with the most powerful creation engine

Get Started Now