Configure HDRP for virtual reality
To use Virtual Reality (VR) in the High Definition Render Pipeline (HDRP), you must enable VR in your Unity Project. To do this, see the VR tab in the Render Pipeline Wizard.
Please refer to Unity XR documentation for more information about XR developement with Unity.
Recommended Settings
Unity has designed HDRP to fully support Single-Pass Instanced mode. This mode gives you the best performance on all platforms. HDRP also supports multi-pass but this is slower on the CPU and some features, like Auto Exposure, can cause issues. If you encounter a problem with a specific feature, you can disable it in your Project’s HDRP Asset.
You can also watch the presentation from Unite Copenhagen (October 2019) to learn more tips: Maximizing visual fidelity in VR: HDRP support
Supported Platforms and Devices
- PC with DX11/DX12/Vulkan:
- Oculus Rift & Rift S (Oculus XR Plugin, Windows 10 and 11, DirectX 11, DirectX 12, Vulkan)
- Windows Mixed Reality (Windows XR Plugin, Windows 10 and 11, DirectX 11, DirectX 12, Vulkan)
- PS4 and PS5:
- PlayStationVR
- Open VR*
Note: Valve is currently developing their OpenVR Unity XR plugin for 2019.3 and beyond. For more information, refer to XR Plugin Architecture. The XR Plugin architecture links to the OpenVR desktop package and has further info and recommendations.
Resolution Control
There are multiple methods that you can use to control the resolution of your render targets in HDRP, but be aware that HDRP doesn't support every method available in standard Unity using the built-in render pipeline. XRSettings.renderViewportScale has no effect in HDRP and generates a warning if you use it. Use one of the following methods instead:
- Dynamic Resolution: You can use the dynamic resolution system to change the resolution at runtime. This is the best method to use if you want to change the resolution at runtime.
- Eye Texture: You can set the device back-buffer resolution by changing XRSettings.eyeTextureResolutionScale. This is a resource intensive operation that reallocates all render targets.
Be aware that SteamVR will apply a default 150% supersampling value. You can change this value in the settings of SteamVR.
Enable VR single-pass after startup
Note: Due to some technical limitations that Unity will resolve in later versions of HDRP, you need the following code in your script if your app doesn't boot directly in VR mode:
private void Awake()
{
UnityEngine.Rendering.TextureXR.maxViews = 2;
}
C# defines
You can use the following defines to include or exclude code from your scripts.
- ENABLE_VR: The C++ side of the engine sets this define to specify if the platform supports VR.
- ENABLE_VR_MODULE: Unity sets this define if your Project includes the built-in VR module com.unity.modules.vr.
- ENABLE_XR_MODULE: Unity sets this define if your Project includes the built-in XR module com.unity.modules.xr.