Toggle stereo rendering mode at runtime

I’m looking for a way to toggle the XR rendering mode at runtime - specifically between StereoRenderingMode.MultiPass and StereoRenderingMode.SinglePassInstanced depending on the scene and viewpoint. Note this is NOT about switching from flat to vr method, but between a SinglePass method (for 90% of the time when performance matters) to MultiPass (where particular rendering feature needs to be drawn separately for each eye).

XRSettings.stereoRenderingMode exists which seems to show the current active mode, but this is read-only at runtime so can’t be changed.

Other details:

  • Unity 2022.3.22f
  • Targeting Quest and SteamVR, so both Android (Vulkan) and Windows (D3D11) platforms
  • BiRP

Yes, I’m aware of UNITY_VERTEX_INPUT_INSTANCE_ID/unity_StereoEyeIndex/etc., but the rendering changes significantly between the two eyes with different passes and different ordering, so not relevant here.
Technically I could use MultiPass all the time, but then I’d be throwing away performance for 90% of the time when it’s not needed.

Thanks

1 Like