Scali April 26, 2005, 06:32 AM 

Yes, if you postmultiply Erik FayeLund's matrix to your projection matrix, you basically get this idea:
Let x, y, z, w be the homogenous coordinates in clipspace, so after multiplying with the original projection matrix...
Then: x' = 1*x + 0*y + 0*z + (2/viewport_width)*h_offset*w y' = 0*x + 1*y + 0*z + (2/viewport_height)*v_offset*w z' = 0*x + 0*y + 1*z + 0*w w' = 0*x + 0*y + 0*z + 1*w
Then the homogenous coordinates will be projected back to w=1 for the perspective:
x'/w = x/w + (2/viewport_width)*h_offset y'/w = y/w + (2/viewport_height)*v_offset z'/w = z/w w'/w = 1
Then the x and y coordinates will be scaled to the viewport:
vx = ((x/w) + (2/viewport_width)*h_offset)*viewport_width/2 = x/w*viewport_width/2 + h_offset vy = ((y/w) + (2/viewport_height)*v_offset)*viewport_height/2 = y/w*viewport_height/2 + v_offset
So there you are, the offsets you've added, are now absolute in terms of screen pixels.
