- Home /
How to split one view frustum between multiple cameras?
Hey all,
I'm doing some experimentation...it might not seem obvious why one might want to do this, but bear with me.
Basically let's say I have one camera with one view frustum. I'd like to be able to render its view instead in a tiled way with 4 cameras. Effectively I'd like 4 cameras each responsible for one quarter of the frustum of the original camera. Their combined output should be exactly the same as the single original camera with one frustum. Their frustums, combined, should cover the same volume as the original camera.
Any ideas how I should set this up? I've tried messing with view port rect and fov but I think I'm on the wrong track... Thanks for any help.
There may be some useful information here : http://answers.unity3d.com/questions/479774/how-to-render-the-same-scene-differently.html
Answer by Eric : Once you have the normalized viewport rects set so each camera is covering half the screen, you can use OffsetVanishingPoint to move the cameras' vanishing points so they match up.
Thanks! After a little bit of testing that seems to have put me on the right track.
I was concerned that using OffsetVanishingPoint wouldn't actually change the shape of the view frustum - e.g. affect collision detection between objects and the frustum - but it appears it does, even though in the editor the frustum's shape isn't altered. That is good :)
Just have to figure out the right parameters now, or a generic formula for working it out for different cameras.
I'm not sure if you want to add your comment as an answer? I'd be happy to accept it as the answer.
Hmm, actually, while this renders things correctly, it doesn't exactly do what I need.
For example if I have two cameras side by side, each rendering half of the view, OnBecameVisible is called when an object passes into either camera's frustum, and a geometry test will pass for both cameras even though it's only visible in one camera's view. I'd like to be able to split the frustum for visibility tests also.
Perhaps I need to construct custom planes and do my testing against those rather than the ones the camera provides.
OnBecameVisible is called whenever any camera, incl. the Editor's scene view, renders an object. Have you looked into layers and culling masks? Could provide a way to have OnBecameVisible only be called for certain cameras.
Answer by rich_seabirdsim · Jul 09, 2014 at 09:26 PM
If I understand you correctly, you just have to get the proper numbers in the rect and fov. But you also have to aim each camera in the proper direction.
So camera 1: x=0; y=0; w=.5; h =.5; camera 2: x=.5; y =0; w=.5; h =.5; camera 3: x=0; y=.5; w=.5; h =.5; camera 4: x=.5; y=.5; w=.5; h =.5;
This should tile 4 camera views for you into a single (100%) frustrum view. Then you'll have to adjust the FOVs as well as the camera rotations so that the cameras are displaying what you want.
Answer by LazyElephant · Dec 18, 2015 at 10:42 PM
What you're looking for is called a Scissor rect. Unity doesn't implement it in their api, but you can do it with a simple script. I go through the setup step by step in this question http://answers.unity3d.com/questions/1112309/screen-is-2-cameras-with-each-different-properties.html#answer-1112586
This sets up only two cameras, but you can easily extend it to more.
Just noticed this was from 2 years ago. I have no idea how it was brought up to the top again, but I'll leave this answer in case anyone else needs it.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
WHY My Camera twitch ????? 0 Answers
is there any tricks while navigating the scenes with the camera 1 Answer
Question about ARcamera 0 Answers
Unity Advanced Water Problems 0 Answers