Jump to content
  • Advertisement
Sign in to follow this  
newtechnology

DX11 Why is this 1?

This topic is 1154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

7rqrAH5.png

Image Source: Frank D. Luna's DX11 book.

 

BTW, can anyone please explain me directx projection matrix and how it's derived.

Edited by newtechnology

Share this post


Link to post
Share on other sites
Advertisement

I'm horrible at math so we can hope that someone that knows more soon answers cool.png . I think that the 1 i related to that the DirectX clipping volume ranges from -1.0 to 1.0. So whatever you set the other values to it needs to work with the 1 there.

 

https://msdn.microsoft.com/en-us/library/windows/desktop/bb206341%28v=vs.85%29.aspx . Search for clipping volume.

 

Ohh that was DX9 i see know. Might be changed with 11.

Edited by Spinningcubes

Share this post


Link to post
Share on other sites

Like Olaf says, its convention and has nice properties WRT how floating point works (namely, there is as much precision betwen 0 and 1 as there is between 1 and the largest number the floating point format can represent).

 

Those are the normalized device coordinates (NDC).

Share this post


Link to post
Share on other sites

Yes, 2 units from top to bottom and from left to right, by convention ranging from -1 to +1 in both axis (again, what I said about precision between 0 and 1 above is also true for 0 to -1. In floating point, the numbers between -1 and +1 encompass exactly half of all the values the format can represent.)

Share this post


Link to post
Share on other sites


by convention ranging from -1 to +1 in both axis

 

That's correct with regard to range.

 

Just to be clear, the ( x, y ) screen coordinates that result are ( -1, +1 ) at the upper-left to ( +1, -1 ) at the lower-right. That represents a Cartesian system with the origin at center-screen, with -X to the left, +Y up, +X to the right, and -Y down.

Share this post


Link to post
Share on other sites

It's called screen space and is the final result of your transformations.

 

The vertices of your objects are transformed from object-local space to world space through the world matrix, so the model is correctly positioned and rotated in the game world.

Then they are transformed again by the View Matrix into view space which means they are now correctly position relative to the camera.

 

All these spaces so far are in standard 3d cartesian coordinates ranging from 0 to INF on all 3 axis.

 

Now as final step through the Projection Matrix the object is transformed into projection space which is a normalized cube with coordinates from -1 to 1 on all sides.

If you flatten this cube to a square you get the Screen Space which is in normalized device coordinates and therefore by definition ranging from -1 to 1 on both X and Y axis.

 

You can for example draw an image to full screen by sending it to the GPU as a quad with XY coordinates 1/1, 1/-1, -1/-1 and -1/1 and applying no transformation.

This is called screen space rendering

Share this post


Link to post
Share on other sites

CLA_jtqWIAAKHKr.png

 

DirectX uses a coordinate system like this, ultimately:

10.gif

 

The projection matrix flattens your 3D view-space coordinates into Normalized Device Coordinates.

Share this post


Link to post
Share on other sites

I think it's kind of confusing showing the normalised device coordinates on the same diagram as the view frustum.

 

It seems like a somewhat separate concept to me, and there's no reason that projection window line couldn't sit to the right of the near plane, or even to the right of the far plane!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!