- Home /
How to render part of FOV?
I have a number of machines networked and I want to show a wide field of view by showing part of that view on each machine.
Obviously if I have 3 machines and I simply attach a camera to the networked "player" and point each camera in a different direction, I will get distortion on the left and right views compared to what I want.
A solution would be to specify the same wide FOV on each camera but to tell each camera to render only a portion of this.
Attached is a diagram where I show the simple version (that results in distortion) at the top and what I want to do at the bottom.
How can I render (full view port) only a specific range of the FOV (e.g. 0-40 degrees from an FOV of 120)?
I've never thought about it, but maybe you could try this, if you have Unity pro :
Use a single camera with a wide fov that render in a render texture. Then use GUI.DrawTextureWithTexCoords to display that texture on screen with those parameters :
Left : (screenRect, renderTexture, new Rect( 0f, 0f, 1f / 3f, 1f ))
$$anonymous$$iddle : (screenRect, renderTexture, new Rect( 1f / 3f, 0f, 1f / 3f, 1f ))
Right: (screenRect, renderTexture, new Rect( 2f / 3f, 0f, 1f / 3f, 1f ))
I thought of that but in my case I'd need a massive texture as each screen might be 1920x1024 or larger... It will also presumable really affect the frame rate because I will have to render 3x the resolution (i.e. 5760x1024). This solution would be in-efficient for memory and bad for frame rate (but I do appreciate your input).
You'd need to render only part of the FOV then, but that doesn't seem possible. I moved my answer here, so you're still marked as unanswered.
Another problem with trying to use a render texture is that the maximum width is 2048 pixels and I need 5760. I was hoping to at least try this method by setting the view port rect to 1/3 of the width and see what happens but without being able to set a big enough texture this solution is a non-starter.
Perhaps there is a way to make a custom camera although I could find no code to inherit from etc.
Any ideas, anyone?
Probably not exactly what you want, but it looks like this guy had some success: http://forum.unity3d.com/threads/93224-how-to-set-up-multiple-cameras-in-a-scene-rendering-to-multiple-displays
Also, maybe you can do something with the camera's viewport?
Answer by Bunny83 · Feb 07, 2013 at 04:49 PM
As i already mentioned in the comment above, just use the second script example on this page. It actually does exactly what you want. You can set the left and right planes manually. For example:
screen leftvalue rightvalue
--------------------------------------
left -0.4 -0.2
center -0.2 0.2
right 0.2 0.4
You can't set the fov directly in this case. Usually the right / left / top / bottom values are calculated from the given fov value and the screens aspect ratio.
You might want to include the aspect ratio as well, but it depends on your actual screen resolution(s).
Do you use 3 identical screens?
O$$anonymous$$, I can see that this is along the right lines but the values you give do not result in what I would expect but it was enough to get me going along what seems the right line so thank you Bunny83.