5
\$\begingroup\$

I am using a right handed coordinate system for my world coordinates (so, positive x goes right, y is up, and z is towards you).

However, after projection and the w divide, nomalised device coordinates range from [-1,1] on x and y, with x pointing right, and y pointing up, and z ranging [0,1] (or [-1,1] in OpenGL) pointing into the screen. This is a left handed coordinate system.

As such, wouldn't the winding order you need to use swap? If my models define front faces using clockwise winding, then it would seem that you must cull clockwise faces in order for the hidden faces to be removed after projection. I don't remember having to do this in XNA (where I wasn't calculating my own matrices and just left the defaults), so have I made a mistake in my reasoning here?

\$\endgroup\$
4
  • \$\begingroup\$ Can you post, how you create projection matrix? \$\endgroup\$
    – zacharmarz
    Feb 24, 2012 at 11:57
  • \$\begingroup\$ @zacharmarz I am using the code from geeks3d.com/20090729/… \$\endgroup\$
    – Aphid
    Feb 24, 2012 at 12:50
  • \$\begingroup\$ And can't be your problem with view matrix? Can you write, how you construct it? \$\endgroup\$
    – zacharmarz
    Feb 24, 2012 at 13:08
  • \$\begingroup\$ Is there an actual problem you're trying to solve or is this just curiosity about the full pipeline? \$\endgroup\$ Feb 24, 2012 at 18:48

1 Answer 1

6
\$\begingroup\$

First of all, X points right, not left, in screen coordinates. But yes, the normalized device coordinates are a left-handed system. It doesn't matter for backface culling, though. From the OpenGL FAQ:

OpenGL face culling calculates the signed area of the filled primitive in window coordinate space. The signed area is positive when the window coordinates are in a counter-clockwise order and negative when clockwise.

It only looks at the triangle in 2D, so if it's anticlockwise-wound in right-handed space before perspective projection, it'll still be anticlockwise-wound afterward; the reflection through the screen plane doesn't affect it. I assume D3D behaves similarly.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Ah yes, I meant to say x points right, I'll fix that in the question. But yes, I was for some reason thinking the projection matrix is doing the left/right swap by negating the x axis, which it doesn't. Negating the z axis wouldn't effect the winding order, as you say. \$\endgroup\$
    – Aphid
    Feb 26, 2012 at 12:09

You must log in to answer this question.

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