1
\$\begingroup\$

We are building agame with orthographic view. The problem we face is the fact that with different resolution you can see different area of the game world. E.g. if you have higher resolution you can see more around you. To solve this we currently use a common scale factor that every model is scaled by, depending on resolution. But this has drawbacks when drawing shadows - I cannot set a higher view angle for the orthographic shadow camera, while when using the perspective shadow camera I get significantly worse shadow quality.

So the question is is there any way to controll FOV when using orthographic projection, or, more specifically, what is the easiest way to scale the world uniformly up or down with orthographic projection matrix?

I saw that in 3ds MAX you can control FOV for an orthographic camera I wonder how they implemented it.

\$\endgroup\$
2
  • \$\begingroup\$ do you mean orthographic projection? and I suggest you post an image of the shadows with different resolutions. \$\endgroup\$
    – concept3d
    Nov 4, 2013 at 14:04
  • \$\begingroup\$ Yes :) I always mix em up). I updated the post. I will post images shortly. \$\endgroup\$
    – cubrman
    Nov 4, 2013 at 14:25

4 Answers 4

4
\$\begingroup\$

In order to scale the projection generated by glOrtho, glm::ortho or any other framework, you just need to divide left/right/top/bottom or width/height by your scaling factor. So if for instance your code looks like this:

proj_matrix = glm::gtc::matrix_transform::ortho(-320, 320, -200, 200);

and you want a “fov” X times as large, you just need to use this instead:

proj_matrix = glm::gtc::matrix_transform::ortho(-320 * X, 320 * X, -200 * X, 200 * X);

Component-wise, this will divide the first two diagonal terms of the resulting matrix by X.

\$\endgroup\$
1
  • \$\begingroup\$ I am so terrible in matrix math I could not even imagine that you can simply multiply a prjection matrix by a scaling matrix and get the correct result. We were multiplying every world matrix of every object instead! Thanks for your comments. \$\endgroup\$
    – cubrman
    Nov 5, 2013 at 9:30
2
\$\begingroup\$

Is there any way to control Field of View when using orthogonal projection ?

| 1/r 0        0       0     |
| 0   1/t      0       0     |
| 0   0    -2/(f-n) -f+n/f-n |
| 0   0        0       1     |

Looking at the orthographic (symmetric) projection matrix above it is a combination of scaling matrix and a translation matrix, and unfortunately doesn't define a field of view. Field of view is a feature for projections that simulate how a human being eye sees the world (e.g. perspective projection).

What is the easiest way to scale the world uniformly up or down with orthogonal projection matrix?

Since you are already using an orthographic projection, which is technically a scaling matrix I would say changing the values of the orthographic matrix by multiplying/dividing the scaling components of the above matrix with some scaling factor. ( I am not assuming you are using a specific library).

But this has drawbacks when drawing shadows ?

Depending on the shadow algorithm you are using, (I suspect shadow maps) maybe you can change the shadow map resolution depending on the screen resolution as to get more consistent quality.

\$\endgroup\$
0
\$\begingroup\$

Orthographic projection has no concept of a FOV, because by definition an orthographic viewing volume is cubic.

Increasing FOV modifies the viewing volume of perspective projection by "increasing the spread" of the view frustum (pyramid).

The FOV of an orthographic projection is actually 0, because the "pyramid" (cube, really) of an orthographic projection does not spread at all.

You need to mod your scaling factor as Sam said.

\$\endgroup\$
0
\$\begingroup\$

All answers here are great. Another explanation: Orthographic projection is the result of lim(fov->0) and lim(d->infinity), where d is the view distance. Thus, you can think of the fov being fixed by the choice of this projection. That is why photographers sometimes prefer longer focal length (smaller fov) and increase the distance to the object: parallel lines stay more parallel with longer focal length.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .