## March 4th 2015, Homogeneous Clip Coordinates

← March 4th 2015 Software Rendering Pipeline | ● | March 25th 2015 Cyanogenmod on LG L7 II →

Recap: the rendering pipeline transforms homogeneous point vectors $\vec{p}=(x,y,z,1)$ with the combined model-view-transformation matrix $M_{MVP}$ as follows:

The resulting projected point $\vec{p}'$ is given as 4-component vector in homogeneous coordinates. For reasons we will see later, this coordinate system is also called the **clip coordinate system**.

After dividing the point by its w-coordinate we get a 3-component vector, where x and y denote the position of the point relative to the center of the image plane. This is also called **normalized device coordinates** (NDC), since NDC coordinates can be easily scaled up to a given window geometry. The z-coordinate denotes the depth (as used by the Z-buffer algorithm).

In NDC coordinates, the visible volume is limited by the unit volume cube from −1 to 1.

Q The question now is: Can we clip a point at the NDC unit cube in order to remove visible points?

The answer is no, because a point with negative w-coordinate is invisible, but may still yield positive z-values after dehomogenization.

As a consequence, we cannot perform clipping in NDC, but we need to perform it one step earlier, meaning we need to perform it in homogeneous coordinates. Hence, the homogeneous coordinate system is also called clip coordinate system.

In clip coordinates the visible volume, that is the view frustum, is not bounded by −1 and +1 as for NDC, but rather by -w and +w. So the condition for a transformed point $\vec{p}'=(x,y,z,w)$ to be visible is:

Q The next question now is: How can we clip a line segment that is partly visible?

The answer is that we simply need to clip it in homogeneous coordinates as well!

Here is how:

Let $\vec{a}$ and $\vec{b}$ be the two end points of a line segment, where $\vec{a}$ is regarded to be outside of the view frustum and $\vec{b}$ inside.

Given a clipping plane $P=(A,B,C,D)$ with $A,B,C,D$ being the coefficients of the according plane equation with $Ax+By+Cz+D=0$, then the clipped point $\vec{a}'$ is:

To clip the point at the near resp. far plane we use $P=(0,0,1,1)$ resp. $P=(0,0,-1,1)$. Other clip planes such as the sides of the view frustum are treated accordingly.

← March 4th 2015 Software Rendering Pipeline | ● | March 25th 2015 Cyanogenmod on LG L7 II →