More perspective junk

Started by
9 comments, last by xg0blin 19 years, 4 months ago
Grasping 3D perspective still seems a bit elusive to me. My current understanding is that you’ve got these logical world space units. By logical, I mean the values that these units represent are scalable depending upon how you treat them to mean. You setup the 3D positioning of your camera and all of your objects. Then you’ve got a few extra options for your camera, near and far planes along with you Field of view/FOV. Most of the documentation states field of view is common PI / 4. The value of PI / 4 is equal to 0.785398163 radians or 45 degrees. This is the angle that the camera sees at in the direction it is looking in. The FOV angle extents outward from the cameras position in the direction the camera is pointing (towards origin in most cases.) Also, along with the near and far clipping planes the FOV creates the pyramid of “displayable data”. The things I’ve mentioned so far are things I am confident in my understanding of. This is where my understanding does get a little shady though. The way the render target and some of the math was setup though, I think Direct3D automatically scales the visible area to the size of the render target no matter what the size of the render target is. The size of the render target in no way affects the amount of visible world space; only the amount of screen space it’s drawn in. After some experimenting I’ve figured out that I really don’t know how D3D decides what to display though! FOV, direction of the camera, camera positioning, and other objects in the scene of course have a hand in all of this. But I think I understand all of what they do. I was thinking FOV would extend outward until it hits the far clipping plane, but it doesn’t. So how does D3D know when to stop trying to render things? Know what I mean? The render target size has nothing to do with what D3D will display I guess, just the scale of what is displayed. So, if it’s not the render target or the clipping planes describing what should be displayed, then what is it? When does D3D know when FOV should stop continuing further on in the direction its heading?
Advertisement
I haven't done much with Direct3d, so I can't help you out with API specific function calls, but perspective is pretty easy to explain.

You have the position of the camera. From that position you can define how much you can see. The near-clipping plane is where do you start seeing. If you look straight ahead right now, with your eyes 90 degrees from the floor, you'll notice that you don't see what is directly below you. The near clipping plane then is used to define how far away from your eye you start seeing things. It's not exactly a pyramid as you suggest (hell you can make it a cube if you want), but generally it is a blunted pyramid with a little bit of the top cut off for your near-clipping plane.

The far clipping plane is how far away you can see. You don't see into infinity so you have to clip somwhere. That is the base of your pyramid. So you see nothing before the near-clipping plane and nothing after the far-clipping plane.

Now for the FOV. This is your field of view in the y-direction (up-down). If you set it high the bottom and the top of your view will move farther apart. If you set it close it moves together. Think of a top and bottom pyramid shape with no sides and moving them up and down. That's what this value is for.

Last, the aspect ratio. The FOV decided you y-seperation, this decides your x-direction. Rather than an actual value in degrees though, this is generally an aspect ratio for how much x you want for every y. For instance, most monitors have a 4/3 aspect ration, it being 1/3 wider than it is tall. This is the same thing really. While the FOV told you how tall to make your pyramid, this tells you how wide to make it in reference to how tall it is.
Why is it that changing the distance of the far clipping plan doesn't squash the items close to me? It should shouldn't it? I say this because D3D would then have to display a lot more into my render target so that means everything would need to be scaled back a little more.. this effect doesnt happen though.
The clipping planes don't determine how close things look, they just determine the closest and farthest things that will get drawn on the screen. If you have a near clipping plane that is pretty far away for example, everything will dissapear when you close to it because it won't be between the two clipping planes any more.

The view angle is pretty much the only thing that effects how things look, though if you really want to can make special projection matrices (which is what translates points from 3D coordinates to 2D screen space) that distort things differently. The usual projection matrix uses the Z coodinate to make far away stuff have less screen space and closer things to have more, but another common one is othrographic projections where the distance to objects is ignored entirely and everything ends up looking like a 2D isometric game.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Extrarius you're exactly right, that was point even though. The far clipping plane doesnt effect what is shown in the display unless the display tries to show something that far away. In other words, the far clipping plane only has to do with upto how far it would render... but not how far it WILL render.

My question still stands though. What is it that defines what will be displayed on the screen? The cameras position and orientation tell it where to look.. the FOV is stating what this camera can actually see. But think about this:

If you resize a window it will just be changing the aspect ratio of what to change, so resizing the window larger or smaller has the same effect on whats shown (if you reset the device as you should .. look at D3D tutorial 6 in the dx9b sdk for an example of what I mean.) The render target size has nothing to do with whats displayed other than how its displayed.

Keep that in mind and think about this, changing the far clipping plane does not change whats shown at all, so this means that the far clipping plane also has nothing to do with how D3D scales parts of the world to be shown onto the screen. So what the heck is? Thats my question guys. FOV sets up the side clipping planes and uses the near and far plane.. but that doesnt effect how D3D determines what to show. Think about this before responding because this question seems to be deeper than everyone jumps to concluding it is.

(I'm not trying to be rude)
Quote:Original post by Keith1977What is it that defines what will be displayed on the screen? The cameras position and orientation tell it where to look.. the FOV is stating what this camera can actually see. But think about this:

If you resize a window it will just be changing the aspect ratio of what to change, so resizing the window larger or smaller has the same effect on whats shown (if you reset the device as you should .. look at D3D tutorial 6 in the dx9b sdk for an example of what I mean.) The render target size has nothing to do with whats displayed other than how its displayed.


You're mixing things up. The resolution of the monitor or the size of the window don't effect what your application shows. That just changes the number of the pixels on the display, and the aspect ratio of the window itself. You're thinking about two different things entirely. The perspective does decide what is shown in your application. Only things that are inside of the blunted pyramid we're describing are shown. That's why changing the size of the shape of the pyramid change what is shown on the screen and what it looks like.

Quote:Keep that in mind and think about this, changing the far clipping plane does not change whats shown at all


Yes it does, if what is shown is in the area where you changed the far clipping plane. For instance, say you have a far clipping plane set at 1000 units, and something is drawn at the 995th unit. You will see that object. Say you change the far clipping plane to 950 units. You will no longer see this object because it will be clipped out, thus the name "far-clipping plane".

Quote:so this means that the far clipping plane also has nothing to do with how D3D scales parts of the world to be shown onto the screen. So what the heck is?


The far-clipping plane doesn't handle the scaling. It handles how far away you can see. If something is beyond the far clipping plane, it isn't shown, end of story.

Quote:Thats my question guys. FOV sets up the side clipping planes and uses the near and far plane.. but that doesnt effect how D3D determines what to show. Think about this before responding because this question seems to be deeper than everyone jumps to concluding it is.


It does determine what to show and how it is shown. If you set the values strangely, you can get fish eye effects or tunnel vision or whatever. FOV doesn't set up the side clipping planes. It sets up the top and bottom clipping planes. The aspect ration sets up the side clipping planes. The word clipping means that anything outside of those planes will be clipped.

The perspective is used to set up a camera and set up it's view. You can set it up to view however you want. You can have it wide-angle, fish-eye or whatever. Think about it like that, as a set of lenses. Certain cameras are better for viewing things at distances and some focus better on things up close. It determines what your view looks like and how much is contained in that view. That is all that it is for, though it could be manipulated for scaling and things of that nature if you wanted to be strange or something. Mostly it makes your view more concave or more convex for the aspect ration and FOV, and the near and far clipping planes are used to clip things out that are too close to you or too far away.
Quote:You're mixing things up. The resolution of the monitor or the size of the window don't effect what your application shows. That just changes the number of the pixels on the display. You're thinking about two different things entirely. The perspective does decide what is shown in your application. Only things that are inside of the blunted pyramid we're describing are shown. That's why changing the size of the shape of the pyramid change what is shown on the screen and what it looks like.


I am working with a window mode application so yeah, I'm working with a resizable window. Anyway, resizing the window wont change the "pyramid" at all will it? Thats all just made up out of FOV, clipping planes, and camera location. Thats why, resizing the window doesn't change the amount of world space shown, only the detail. Am I right? .. thats what I meant maybe I said it wrong or still am wrong.

Quote:Yes it does, if what is shown is in the area where you changed the far clipping plane. For instance, say you have a far clipping plane set at 1000 units, and something is drawn at the 995th unit. You will see that object. Say you change the far clipping plane to 950 units. You will no longer see this object because it will be clipped out, thus the name "far-clipping plane".


You're right and I do actually understand that, poor wording on on my end I guess. But taking the tutorial I previously mentioned, tutorial 6 of the D3D section in the DX9b SDK, and changing the far clippling plane to any outragous number will not rescale anything thats being shown. Ok sure it would cause an item past that clipping plane to be clipped, but the thing is that D3D doesnt seem to even be showing back to that clipping plane? If it were, changing the clipping plane distance would mean that the distance shown in the camera would change and that would FORCE rescaling. Right? that again is what I am saying, could have said it wrong.

Quote:The far-clipping plane doesn't handle the scaling. It handles how far away you can see. If something is beyond the far clipping plane, it isn't shown, end of story.

Already covered.


Quote:It does determine what to show and how it is shown. If you set the values strangely, you can get fish eye effects or tunnel vision or whatever. FOV doesn't set up the side clipping planes. It sets up the top and bottom clipping planes. The aspect ration sets up the side clipping planes. The word clipping means that anything outside of those planes will be clipped.

Changing any clipping planes wont do anything except change what is drawn and what is not, but it has nothing to do with how its drawn. The only thing that effects whats drawn, that I know about, is the asepect ratio and FOV. D3D knows what to draw with out ever taking window size into account until its time to draw.

The clipping planes don't seem to be all of what you think.

I really wasn't trying to be rude, but one of us aint getting something.
I think I understood your question, so let me try to explain what I meant. If I'm still not answering your question, when I must be misunderstanding it still. It sounds like yo'ure asking how D3D determines what is visible and how it determines what it looks like.

The clipping planes determine what will projected on your screen. If something is within the clipping volume, then it MIGHT be visible and it is projected using the projection matrix to figure out where on the screen it might be. If the object is outside the clipping planes, then it is essentially discarded and ignored.

The projection matrix determines the 3D->2D mapping and thus determine how things look on the screen. It is possible that the clipping planes say the object is visible, but the projection matrix puts the 2D coordinates of it off the screen and you still won't see it.
It also determines how far away stuff looks, because it controls what effect the z coordinate (and all other coordinates) have on the final vertex location.

The 6 clipping planes (that are usually shaped like a pyramid with the top point cut off) determine what is processed, and the projection matrix determines how the processed stuff gets shown on the screen.
FOV affects the clipping planes and projection matrix, and the aspect ratio is used with the FOV to figure out how stuff on the ScreenX axis relates to stuff on the ScreenY axis.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Quote:Original post by Keith1977I really wasn't trying to be rude, but one of us aint getting something.


Well, I guess I'm confused as to what you are asking then. You seem to be very confused about what a perspective projection is even for, likening it to window size and resolution, and stating things like it doesn't change what is drawn. That led me to believe that you didn't even understand the basics behind what a perspective projection was used for, so I attempted to explain them. Because of this apparent misunderstanding you have of the concept itself, I am having a hard time understanding what it is that you don't understand about it. Perhaps you should reword your question. I'm not trying to be rude either, but when you make statements like this to people who are trying to help you out it tends to be a tad put-offish. Perhaps rewording your question in a more understandable way, and clueing us in as to exactly what you don't understand about perspective projection would help, rather than putting it the way you just put it.
xg0blin - I'm pretty new to this subject so there are some things I may misword that I actually understand to some extent. Its hard to word things you may not fully understand or are new to. Your explaination did clearify a bit actually, and I thank you for it. On the other hand, you were being rather rude actually and I believe that was some of the intent.

Extrarius - hot, thanks man. Not knowing that the entire pyramid isn't actually displayed helps; I think thats the main conflict I had with xg0blin.

Knowing all this is going to help me solve my current, actual, problem. Maybe I should make it in a different post so people dont have to read all this before getting to it? Anyway:

I've got a window mode game that gets resized. When its resized though I want to actually change the amount of the world viewed instead of just rescaling the same amount of the world. I know I'd do this by FOV, but I'm not sure the math that would be required to figure out what to change it to. I'm trying to get the origin (where the camera is pointed) to be the same scale after all resizes.

This topic is closed to new replies.

Advertisement