•      Sign In
• Create Account

### #ActualHodgman

Posted 18 December 2012 - 08:02 PM

D3D and GL each have different types of projection matrices, due to the fact that they each define "Normalized device coordinates" (NDC) differently. After projection (and perspective division, etc), you end up with points in NDC-space, which are then transformed to view-port space, and drawn as pixels.

In GL, NDC is a "unit cube" from -1 to 1 in every axis.
In D3D, NDC is -1 to 1 in x and y, but 0 to 1 in z.

Because of this difference, D3D and GL require slightly different matrices, in order to correctly transform your input vertices into the right kind of so-called "unit cube"

With your results, where negative z values cause a kind of "backwards projection", it sounds like you're using a D3D-style projection matrix? -- in which case, 0/1 for z should give the correct results.

### #1Hodgman

Posted 18 December 2012 - 08:01 PM

D3D and GL each have different types of projection matrices, due to the fact that they each define "Normalized device coordinates" (NDC) differently. After projection (and perspective division, etc), you end up with points in NDC-space, which are then transformed to view-port space, and drawn as pixels.

In GL, NDC is a "unit cube" from -1 to 1 in every axis.
In D3D, NDC is -1 to 1 in x and y, but 0 to 1 in z.

Because of this difference, D3D and GL require slightly different projection matrices.

With your results, where negative z values cause a kind of "backwards projection", it sounds like you're using a D3D-style projection matrix? -- in which case, 0/1 for z should give the correct results.

PARTNERS