- Home /
How to vertically stretch camera view
What I have is two cameras in the exact same location in a scene, but they are both sharing a Normalized Viewport Rect of half width, such that the game view has a vertical split screen appearance. I am trying to make game compatible with a head-mounted display for my class, and as such, i need both cameras to produce a vertically stretched rendering of the scene, something similar to this image:
I am looking for either an inspector-based or scripted solution. Thanks in advanced!
Answer by Yokimato · Mar 28, 2013 at 08:43 PM
You're not going to be getting it from the default camera editor options. You'll need to create a script which overrides the projection matrix of the camera. If you're not familiar with what the projection matrix is, or how it works, I hope you're comfortable with trigonometry functions, as it's required to get a firm grasp.
Once you understand how it works, you can definitely make your changes encapsulated into a variable which is in turn exposed to the editor.
Here's is the property on Camera
you're going to set to your custom projection matrix: http://docs.unity3d.com/Documentation/ScriptReference/Camera-projectionMatrix.html
Thanks for the response. Do you have an idea as to what kind of matrix would produce a "50% width" effect?
3 years later
cam.ResetProjection$$anonymous$$atrix();
var m = cam.projection$$anonymous$$atrix;
m.m00 = 2; // width m.m11 = 2; // height
cam.projection$$anonymous$$atrix = m;
Answer by ClaudioPasca · Nov 11, 2016 at 12:12 PM
Easy way
https://www.reddit.com/r/unity_tutorials/comments/4su2lf/how_to_stretch_what_the_camera_renders/
Your answer
Follow this Question
Related Questions
Network restrictive rendering 1 Answer
Minimap Camera Question 1 Answer
Using multiple cameras (split screen) with LWRP? 0 Answers
Camera rendering help. 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers