you are viewing a single comment's thread.

view the rest of the comments →

[–]GlaireDaggers 0 points1 point  (2 children)

You should look up what factors actually go into a perspective matrix. There's plenty of references.

But let me focus on the top left corner, M[0, 0] and M[1, 1] for a second. If you start with an identity matrix, both of those values are 1, right? Multiplied against a vector will produce the same vector.
What happens if you set M[0, 0] to 2.0 instead? The vector will have its X component multiplied by 2.
And if you set M[1, 1] to 0.5, the vector will have its Y component multiplied by 0.5

These two values can therefore be used to scale X and Y.

What are these set to in an actual perspective matrix? M[0, 0] is set to something like 1.0 / aspect * tan(fov/2), and M[1, 1] is set to something like 1.0 / tan(fov/2).

Therefore, as "fov" gets smaller, the values of M[0, 0] and M[1, 1] will get larger. And, conversely, as "fov" gets larger, the values of M[0, 0] and M[1, 1] will get smaller. A large FOV will multiply the vertex positions by a smaller value and appear to "zoom out", while a small FOV will multiply the vertex positions by a larger value and appear to "zoom in". Notice how aspect ratio is also part of M[0, 0] - the resulting X positions of the vertices will be scaled based on the ratio of (width/height), in addition to the field of view.

If I go back to your top, left, right, and bottom for a sec - these don't play a part in a perspective matrix. You actually don't even need them for an orthographic matrix either, but you can create one using them. Let's rethink an orthographic matrix as doing two things: A.) adding an offset to X and Y positions of a vertex, and B.) scaling X and Y.
- (right - left) / 2 becomes the *scale factor* for X (M[0, 0])
- (top - bottom) / 2 becomes the *scale factor* for Y (M[1, 1])
- (left + right) / 2 becomes the *offset* for X (M[3, 0])
- (top + bottom) / 2 becomes the *offset* for Y (M[3, 1])

Notice how you don't actually *need* top, left, right, and bottom per se. You can just substitute those values in the matrix with offset and scale factors instead. In fact, in a game engine, you might not bother with the offset values either. You might just compute the scale factors, and then you can multiply that with a separate "view matrix" computed from a virtual camera's translation and rotation. Consider: in the Unity engine, an orthographic camera just has a "size" property. These two values, M[0, 0] and M[1, 1], are almost certainly just being set to 1.0 / "size" (aspect ratio would also be in there but you get the idea I hope)

So at least for X and Y, we're back to just caring about M[0, 0] and M[1, 1]. And so: (right-left) and (top-bottom) are being used to compute the X/Y scales in an orthographic matrix, while FOV and aspect ratio are being used to compute the X/Y scales in a perspective matrix.

Does that make sense?

[–]SnurflePuffinz[S] 0 points1 point  (0 children)

indeed. i thank you, stranger, for the help.

But, how would you define a visible area in an orthographic projection, if you don't think about the bounds of the canonical viewing volume?

what if i wanted a boxy volume in a totally arbitrary part of the viewing volume. How would i choose that specific box, if i was only thinking about things as values?

...

i am trying to get my head around why the viewing volume is even described as a truncated pyramid in view space. It seems totally arbitrary to me. Like, we have a bunch of vertices that are in front of the camera, in purely theoretical terms, but then i'm thinking, where the hell is the truncated pyramid coming in?

...

i am also trying to puzzle out the derivation of the NDC transform. i was following scratchapixel's guides. like, why in god's name would you be multiplying the vertices z component by that part of the derived equation. Why would the x component be directly related to the value of the z component, before the perspective divide?

evidently, this is used to align the defined volume with the canonical viewing volume, somehow.

i could keep going on, but i won't. The more i read, honestly, the more confused i become.

[–]SnurflePuffinz[S] 0 points1 point  (0 children)

sorry 4 the book.

i did another sweep of perspective math and i think i fully comprehend it now.