[SOLVED] Adjusting FOV to render part of the screen

Hi, my issue is that I want to render a screenshot which has a different aspect ratio than my screen size.
I simply make a render texture of the size I want and render with the current camera. But when I render an image whichs ratio is wider than my screen then the result is wrong.
I would have to increase the field of view, but how would I calculate the value? It seems to be dependent on the cameras initial fov.

I could simply render the full image and cut out the part I need but that isn’t the ideal solution.

I stumbled across the term scissor rect but I am not sure if that really is what I need as this is just rendering parts within the screen, right?

Unity’s camera FOV setting defines the vertical FOV angle. If you increase the horizontal screen resolution the horizontal view will get wider automatically to account for the difference, but if you increase the vertical resolution the amount you see vertically does not change and instead the horizontal view changes to accommodate the new aspect ratio.

This is not wrong, just it seems not what you’re currently looking for. Using a fixed vertical FOV assignment has the benefit of handling widescreen monitors the way most people expect them to be handled, i.e.: going from a 4:3, to a 16:9, to a 21:9 monitor incrementally increases the amount you can see horizontally.

I’m not entirely sure what you’re looking to get from your higher resolution render. Are you looking to keep the horizontal FOV fixed and adjust the vertical FOV instead, or do you want the higher resolution image to have the same horizontal and vertical FOV as the original view regardless of the aspect ratio of the render target?

If you want a constant horizontal FOV, you need to calculate the horizontal FOV of your current camera and then calculate the appropriate vertical FOV for the aspect ratio of your render target.

If you want to keep both vertical and horizontal FOVs you can temporarily override the aspect ratio on the camera to use the original view resolutions’s aspect ratio.

2 Likes

Thanks for the explanation, I am familiar with the concept, somewhere you have to put the anchor. The examples seem to be what I need, I will give it a try soon. I thought that I need some trigonometry here. But I will also give Camera.aspect a try.

EDIT: Camera.aspect will only stretch my image on the x axis, not what I need.
Also that first example may not work out, I mean how would I know what the correct horizontal Fov is? At least it is getting closer. Maybe I can calculate hFov from vFov of my screen and then use that value. I will try this out later next week when I am back to the project.

Anyway I made an example of what I want to achieve. I simply have a preview of the screenshot area which has a different aspect ratio, the resolution itself doesn’t matter here. All I need is to make sure that the result is the same as shown in the preview area.
The image marked with an X is what I get, but the one below is what I need.

Ok I think I solved it by calculating hte hfov from the vfov of the screen according to this thread:

Then I use the hfov in the code of that post:

Thanks for the hints.