Perspective InterpolationI am trying to get my head around perspective correct interpolation. There is no issue understanding how it is supposed to be implemented, but the idea of it seems to be pretty strange. The idea is, even after you have projected your vertices into clip space that the vertex attributes need to be corrected for the perspective - even though the vertex positions themselves have been projected with a perspective projection.
After thinking about it for a while, the even though from the last sentence should be changed to because of! It really only makes sense that for a given vertex, if its position is 'perspectified' (not a real word but you know what I mean[grin]) then its attributes must be 'perspectified' as well.
When testing out the rasterizer, the screen shots in my previous posts were all generated with a perspective projection, but the four vertices were always co-planar to the viewing plane. This doesn't create any perspective distortion, and essentially negates the need for perspective interpolation. This can be seen here:
However, if the vertices from one side of the square are moved closer to the camera, a perspective distortion occurs. The position of the vertices are perspectively correct, but the attributes (texture coordinates in this case) are not correctly interpolated. This can be seen here:
I'll post some updated screens once the perspective interpolation is up and running. It's good to understand these issues, because if you never worked on a software renderer, then the hardware API will always hide this type of operation from you. So its a great learning experience - try it out, its worth it!