# How to interpolate vertex while clipping in homogeneous clip space?

I want to clip triangles to the near plane, in homogeneous clip space, so for each edge, I have to see if it crossed the near plane. If it has, I linearly interpolate the two endpoints based on the intersection point.

The problem is that this works well in view space, because we only have to compare the vertices' $$z$$ against the near plane. But in homogeneous clip space, $$z$$ goes from $$-w$$ to $$w$$, and this $$w$$ is different for each point! So how can I perform the clipping in homogeneous clip space, and then interpolate the attributes based on the intersection point, if the two endpoints don't have the same near plane ($$w$$ are different)?

• You use the exact same math, except in 4 dimensions instead of 3. – Nicol Bolas Aug 9 at 16:25