URP Second Monitor Stretched - Ideas on how to fix in C#?

Hello there,

I have encountered a bug by which if you build with URP instead of the built-in render pipeline, a multi-monitor setup will see the secondary monitor image stretched.
The build is for a Windows Standalone x86 64bit (Mono).

I tried:

Display.Activate(width, height, refreshRate);
Display.SetRenderingResolution(width, height);

Specifying the resolution has no effect. It’s exactly like simply calling:

Display.Activate();

When building a standalone application with the built-in renderer, everything works well out of the box, the displays are already set in Windows at their default (and only) working resolution. The app fills them in fullscreen mode and calls it a day.

Checking with:

Display.displays[I].systemWidth;
Display.displays[I].systemHeight;
Display.displays[I].renderingWidth;
Display.displays[I].renderingHeight;

And they all return correct values.

My guess is that there is some rendering to texture going on under the hood and the aspect ratio is not picked correctly.
How would I go about troubleshooting this?

I tried also checking:

Camera.aspect;

On the Camera linked to Display 2, the aspect value is equal to the MainCamera, yet this doesn’t seem to have any effect, even if I set it to the correct aspect.
Checking:

Camera.rect

Returns a correct vector (in my case: 0, 0, 1600, 800).

The only thing I can think of is an issue with transform matrixes in the rendering to texture under the hood.
I understand URP does it anyway automatically, in order to manage the resolution dynamically in order to protect the refresh rate from falling.

Wow it feels like absolutely no one is active on this forum.

Anyway I found a solution to work around this bug:

Camera.rect = new Rect(0.5f,0f,1f,1f);

Then give it some time, maybe just one frame

Camera.rect = new Rect(0f,0f,1f,1f);

This will magically bring Unity to render properly.

BTW, for some reason, the fix only works if the rect is changed at Update(), not in a coroutine.

Hi @Ascanio1980 , I am about to try multi-display with URP. Multi-display, in general, over the last several years has been unstable with display scaling having issues and other problems. I am going to try and use the latest version in hopes of getting to the next LTS. Could you tell me where things came out with this for you? Are you using the same workaround today?

Multi-display seems to be working very well with URP for me so far, so you can ignore my question. Thank you.