Quote:
Originally Posted by mc6809e
Oh, I just meant that since the CPU is usually busy with other calculations of all sorts while the blitter is less taxed, adding a cross product calculation for a surface normal plus dot product to see its relation to a ray from the camera just adds more calculation to an already burdened CPU. It might be worth it just to give the blitter more work even if the blitter would take more time, assuming it runs concurrently with the CPU. It would depend on how much internal operation the CPU was performing (plenty for multiplies and divides).

well first off, it occurred to me overnight, if you are not doing hidden surface removal, you can take your number of DMA cycles and double it! Well my intuition tells me a few multiplies would still be worth it.
We need to calculate a predicate based on a vector triple product of the triangle vertices (assuming we are working with triangles, but any face visibility can be calculated from any coplanar triangle).
P = (Ay.Bz  Az.By).Cx + (Az.Bx  Ax.Bz).Cy + (Ax.By  Ay.Bx).Cz [1]
= Ay.Bz.Cx  Az.By.Cx + Az.Bx.Cy  Ax.Bz.Cy + (Ax.By  Ay.Bx).Cz [2]
= (Bx.Cy  By.Cx).Az + (Ay.Cx  Ax.Cy).Bz + (Ax.By  Ay.Bx).Cz [3]
= {(Bx.Cy  By.Cx)/(Bz.Cz) + (Ay.Cx  Ax.Cy)/(Az.Cz) + (Ax.By  Ay.Bx)/(Az.Bz)}.(Az.Bz.Cz) [4]
but we already did Ax/Az, Ay/Az &c because these are just the screen coordinates of the points! so let ax = Ax/Az... and we don't care about multiplying by (Az.Bz.Cz) at all because we only want the sign of the result, not the magnitude! So assuming all of these are positive (but we can just use XOR otherwise)...
p = bx.cy  by.cx + ay.cx  ax.cy + ax.by  ay.bx [5]
= (axcx)(bycy)  (aycy)(bxcx) [6]
Sign(P) = Sign(p) xor Sign(Az) xor Sign(Bz) xor Sign(Cz) [7]
This is only two multiplications and it is good as long as none of the Z coordinates are zero (in which case we can't really compute the screen coordinates  but it simplifies [3] for us).
Quote:
My intuition tells me something else, but that's not proof of course. I want to say that any object for which surface normals work should also work using Zsorting. I have no proof though so I'll have to think about it more.

How do you Zsort a planar object anyway? Sorting points is easy, but which point do you use? The centre of mass?
Consider the following shape:
The sides of the polygon are "walls" from the perspective of the viewer at the bottom. Sorted by their centre point, we can see that faces 4 and 5 get incorrectly drawn over the top of face 3.