Multi-Display rendering offset when displays have different resolutions
Hi Everyone,
I am creating a game (it's actually more of an application/useful software than a game) which needs to be run on multiple monitors, where all monitors are potentially different resolutions.
In the example below, you can see the primary monitor (far left) rendering a full screen camera view, just as it should. There are two other cameras set to render to monitor 2 and 3. These are activated with Display.displays [1].Activate (1600, 900, 50); (so as to set their resolutions to 1600x900).
The issue is that Unity appears to be offsetting the camera rendering so that it does not originate from the top left of the screen, but rather some way down the window. The grey area shows the area where the image is missing. It has seemingly been moved downwards rather than cropped.
When running in the editor, the cameras render each window perfectly with no strange offsetting/cropping.
What do I need to do in order to get the standalone output to render the correct, uncropped/offset image in each of the windows, please?
If I make the resolution of all monitors the same, it renders exactly as it should do:
O$$anonymous$$, having actually done more digging this IS a known bug, and is fixed in the next version of Unity:
Ok, I can confirm that this is FIXED and works GREAT in Unity beta version 5.4.x. I'm using the latest built, 5.4.0b19, and I get perfect displays on both differently sized monitors with this code:
Display.displays[1].Activate(); // Activate the second display
That's right! You don't need any other SetRendering or SetParams() functions - it just works based on the native resolution of the monitor. You ALSO do NOT need to use the -multidisplay command line option, so you can go back to double clicking the .exe.
Yay! Thanks Unity!
sorry but do you NEED actual monitors to use multi display? If I would like to try how should i do it?
Answer by Shawn_Flanagan · May 15, 2019 at 09:15 PM
I just found this issue in Unity 2019.1.2f1. I don't understand why it's not fixed yet. If all my monitors are set to the same resolution, there is no problem. But if any monitor is set to a different resolution, then it incorrectly renders the image for that monitor using the resolution of the main display.
same here, has anyone found a solution yet?
I am trying to have a scene with one screen at 1920x1200 and the other one at 800x600 and it looks like the rendering on the second monitor assumes the same size as the primary monitor. Playing around adding "-multidisplay", setResolution and more won't work.
That's almost identical to my experience/needs. As far as I can tell, there's currently no way to get this situation to work using the multi-display functionality built into Unity.
The best solution I found is what $$anonymous$$arl Jones suggests on this forum page:
the best approach it to just launch the application separately for each window and have them communicate with each other via some interprocess communication. The simplest thing to do would be to network the clients. https://docs.unity3d.com/$$anonymous$$anual/UNet.html This way the screens can be on the same machine, multiple machines or even different devices (mobile map etc)
i just updated from 2018.3.5f1 to 2019.2.0f1, arrrrgggghhhhhhh. HEEELLLLLPPPPPP
Answer by Stonesand · May 27, 2016 at 04:29 PM
I'm having exactly the same problem. I'm using the "-multidisplay" command line option (which sure feels like a hack, and isn't very portable).
You can find that option on the bottom of this page: http://docs.unity3d.com/Manual/MultiDisplay.html
Some more observations, and a workaround (partial success):
1) It doesn't matter what arrangement of the monitors I make in Windows. They can be above each other, to the side, vertically staggered, it has no effect on the offset nature/black bars on the secondary monitor.
2) Even when I force the Displays in code to use the same resolution, in this case the native resolution of display 1:
Display.displays[0].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight);
Display.displays[1].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight);
...this still puts black bars on the secondary monitor, and offsets the screen down off the edge of the monitor.
3) If I go into Windows and set the monitors to all use the same resolution, it all works! I get correct display on each monitor! Except there's a serious downside: my monitors don't have the same native resolution, nor are they the same aspect ratio. Thus, the monitors that aren't being set to their native resolution look fuzzy and have letterboxing!
I'll keep experimenting, but I think this system just isn't fully baked yet. Ideally, each display should be able to use it's own native resolution!
Nah, this is just bugged. :) Even if I try something like this:
Display.displays[1].Activate(Display.displays[1].systemWidth, Display.displays[1].systemHeight + 180, 60);
Display.displays[1].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight + 180);
Display.displays[1].SetParams(Display.displays[1].systemWidth, Display.displays[1].systemHeight + 180, 0, -180);
... it still doesn't work. That 180 value is the difference in height between my two monitors (1080 - 900). That SetParams() function raises the displayed area on the second monitor up so that at least the display is centered - but no matter how much I change the values, it always chops the bottom 180 pixels off. If I set the last height parameter of SetParams() as 0, it fills the top in with black. If I set it to 180, I can see my desktop on the bottom of the display.
No matter what, if there's a screen height difference, the second display will be missing the difference in height in pixels.
Answer by txusillo · Jul 23, 2016 at 05:47 PM
As @stonesand confirms, this is a known bug to Unity developers, there's nothing much to do about it.
I've just downloaded the beta version of Unity and this seems to be working properly now. You should give it a go.
Answer by Vorrin · Oct 25, 2016 at 11:02 AM
I'm on 5.4.1f1 and I still have this problem, if I use any image effects on either camera.