0
$\begingroup$

I'm confused about what orthographic projection matrix outputs. Based on what I know so far, orthographic projection matrix converts vertexes in eye coordinates into clip coordinates. But what exactly are clip coordinates? What are its bounds of x, y, z values? I read somewhere that its x, y, z are all in range [-1...1]. Is it true? Also, how and why axes are orientated in clip coordinates? right handed (z goes out of page) or left handed (z goes into page)? What are main differences between clip coordinates and normalized device coordinates?

Edit: I think the primary difference between clip coordinates and NDC is that NDC can be obtained by dividing clip coordinates by w (ie. $x_{ndc}=x_{clip}/w$, $y_{ndc}=y_{clip}/w$, and $z_{ndc}=z_{clip}/w$. But what I don’t understand here is that even though clip coordinates x,y,z values obtained by projection matrix are in range [-1...1], is it still necessary to divide them by w to get NDC?

$\endgroup$
3

1 Answer 1

1
$\begingroup$

You are running on a few false assumptions here. Whoeever told you that "x, y, z are all in range [-1...1]" for clip coordinates was wrong, or explained it badly, or was misunderstood.

First of all, the clip coordinates can have all kinds of values. Afterall, they resulted from putting your whatever-natured objects through the transformation pipeline. The NDC coordinates of all visible points will be in the [-1,1] range. And that is where clipping comes into play, the operation that the "clip space" takes its name from. Clipping is when you cut your primitives (i.e. triangles and lines, technically also points, but practically you either cull these or not) so that they are inside the viewing volume, which in clip space means coordinates not in [-1,1], but [-w,w].

Sounds weird to have a different interval for each point and what is this 4D space anyway? Well, that's what makes clipping a bit complicated. You can't just cut lines and triangles to the viewing volume in 3D, as for perspective trtansformations that might result in things behind the camera being shown or lines crossing from front to back and all kinds of weird stuff. Really, though, I leave explaining the mathematics of 4D projective space and homogenous coordinates to a proper learning resource with cool pictures. The bottom line is, you need to clip primitives in 4D homogenous space for them to behave properly under perspective projection. And that is what clip space is for.

After clipping, all cordinates are within the [-w,w] range and in NDC space, after dividing by w and thus realizing any actual perspective distortion, all coordinates are within [-1,1] and ready for the viewport transformation.

Why clip space (and thus also NDC space) is left-handed is a bit of a question of taste and tradition, based on the fact that OpenGL's depth buffer uses 1 for the back and 0 for the front. But nowadays you can pretty much change this up to your liking anyway.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.