New Z value when Scanline++
As we move across a scanline (increment X), the new Z value is simply
However, when we change scanlines, the new Z value will be
Z_new = Z_old + dz/dy + (leftX_new - leftX_old)*dz/dx
where Z_old is the starting Z of the previous scanline. Note that:
Eleft.dxdy = leftX_new - leftX_old
Z_new = Z_old + dz/dy + Eleft.dxdy * dz/dx
Zdscan = dz/dy + Eleft.dxdy * dz/dx
Then each scanline increment, we compute the new Z as:
Note that Zdscan has to be computed only once for each subtriangle, at the same time that dz/dx and dz/dy are computed.