- Home /
2 Cameras 1 UI
I'm making some software that uses a 3D projector for the display. I have two cameras (left/right), they render the scene as side-by-side images so the projector can split the input video feed and display the left and right images as it needs.
I have a UI in camera space, however I can only link the UI to one camera but I need it linked to two.
In the attached example I have the stereo-camera output from unity (with the adjusted aspect ratio to compensate for the stretching the projector does). What I'm trying to achieve is a canvas in both cameras (the black buttons) that have the same offset (zero disparity)
I could create two UIs (UI Left, UI Right) and link each one to a camera (Left, Right) and just update them both but that's a lot more work and messy to manage.
If I create the UI in screen space it wont have the correct aspect ratio and will also be split in half by projector.
Any ideas?
It's as if I did that to get people to read it ;)
Sorry, I didn't get your reason of aspect ratio. What's the problem again if you use Screen Space - Overlay?
A 3D projector splits the input video in half and stretches it to fill the whole screen. Check out some examples on youtube (https://www.youtube.com/watch?v=u0hm$$anonymous$$t5znX0) The image in each camera is 'squashed' so that when they are processed by a projector in side-by-side mode the projector stretches the image back out to fill the screen. I guess I should relabel the diagram to "desired projector output".
"If I create the UI in screen space it wont have the correct aspect ratio and will also be split in half by projector."
I don't see why it would be split in half. Though I do see how it's width would be doubled. Why not make the UI with 1/2 width by default, and/or adjust the UI sclae on startup based upon the apect ratio. This should be a single line of code, if you make all UI objects the child of some "base UI scaling" object.
Because the projector takes the input video (1920x1080), splits it into two video streams of (960x1080), resizes each stream back to (1920x1080), it then flashes the two video streams alternately (for left and right eye). Yes I could set the UI to screen space and adjust the aspect ratio, however it will only ever be displayed for one eye at a time (left or right). I need to add the UI to the screen space twice somehow...?
Ah, I see. So why not put the UI in the same world space as your cubes? (and scale by aspect ratio, at startup). Because it would get doubled... never$$anonymous$$d, I see now. hmm. Theoretically, you could offset the UI's worldspace position, when you switch camera's, such that it would appear at the same screen-space position for both camera's. That's some serious math tho. Edit again: But YOU, are not switching the camera's, so you would need both positions displayed at once. hmmm.
Answer by Glurth · May 27, 2016 at 04:39 PM
ok another idea: though I'm not sure how you get the two camera's to combine into a single stereo output screen, but can you use that same method to output TWO MORE cameras to the same screen? If so, those two camera's can be filtered to show only the UI, and you can adjust their position to NOT stereo-scope the result (by giving them the same world-position).
Great! I'm interested, so please come back and let me know how it works out!
That worked a treat :) - I have a world space UI - Two more (UI) cameras at the same location as the left stereo - Each 'ui'-camera is set to UI culling mask and clear flags as 'depth only' - The viewport of each 'ui'-camera is set accordingly to fill each half of the screen - The aspect ratio is adjusted on runtime to compensate for side-by-side projector distortion
Submit it as an answer so I can accept it.