Modifying XRSettings.renderViewportScale results in incorrect rendering with ScriptableRenderContext.DrawRenderers

Hi! We have ran into this issue after upgrading from Unity 2021 to 2022 where setting XRSettings.renderViewportScale on runtime causes ScriptableRenderContext.DrawRenderers to render incorrectly. The exact version being tested is 2022.3.42f1, using URP and we ran the build on the Meta Quest 2 headset with multiview enabled. The issue can be reproduced easily by adding a RenderObjects render feature that overrides the material.

I’m adding a screenshot below with a side-by-side comparison. On the left the object is rendered with XRSettings.renderViewportScale set to one. No issues here. If the scale is set to a value smaller than 1, the object is rendered with an offset and a bit skewed, as shown on the right side.

I guess this is somehow related to the view and projections matrices used in VR, but I haven’t found a way to fix it. Looking at the code of RenderObjectsPass, they explicitly disallow modifying the view and projection matrices in XR. Has anyone had this issue too? Thanks!

2 Likes