The difference between parallel and perspective projection.
Deriving parallel projection equations from perspective projection equations.
Let (x', y') = The screen coordinates.
Let P = Any Point on the polygon's plane.
Let T = Texture point in texture coordinates.
Let C = Point on the polygon to be the texture map's origin.
Let N = Normalized vector that is orthogonal to the polygon's plane
Let U = Normalized vector on the polygon's plane that points in the
direction of increasing x in the texture space.
Let V = Normalized vector on the polygon's plane that points in the
direction of increasing y in the texture space.
zoffset = infinity
d = zoffset
z' = z + zoffset
Cz' = Cz + zoffset
(x'* z' ) (y'* z' ) ( )
Tx = Ux * (------ - Cx) + Uy * (------ - Cy) + Uz * (z' - Cz')
( d ) ( d ) ( )
Tx = Ux * (x' - Cx) + Uy * (y' - Cy) + Uz * (z' - Cz')
Tx = Ux * x' + Uy * y' + Uz * (z + zoffset - Cz - zoffset) - Ux * Cx - Uy * Cy
Tx = Ux * x' + Uy * y' + Uz * z - [U,C]
( Nx*Px + Ny*Py + Nz*Pz )
z = (----------------------------)
((Nx*x')/d' + (Nx*y')/d' + Nz)
z = [N,P] / Nz
Tx = Ux * x' + Uy * y' + Uz * ([N,P] / Nz) - [U,C]
Tx = [U, (x', y', 0)] + Uz * ([N,P] / Nz) - [U,C]
Ty = [V, (x', y', 0)] + Vz * ([N,P] / Nz) - [V,C]
Tz = 0
Applying the parallel projection equations.
struct TexDrawInfo
{
TexImage image; // The image to use in texture mapping.
Vector3D u; // Vector on the polygon's plane that points in the
// direction of increasing x in the texture's space.
Vector3D v; // Vector on the polygon's plane that points in the
// direction of increasing y in the texture's space.
Vector3D n; // A vector that is orthogonal to the polygon's plane.
real u_off; // The [U,C] constant offset as shown in the discussion
// on texture mapping.
real v_off; // The [V,C] constant offset as shown in the discussion
// on texture mapping.
}
Let (x', y') = The screen coordinates.
Let (x, y, z) = The coordinates for the position of the texture point.
Let P = Any point on the polygon's plane.
Let T = Texture point in texture coordinates.
Let C = Point on the polygon to be the texture map's origin.
Let N = Normalized vector that is orthogonal to the polygon's plane
Let U = Normalized vector on the polygon's plane that points in the
direction of increasing x in the texture space.
Let V = Normalized vector on the polygon's plane that points in the
direction of increasing y in the texture space.
Tx = [U,(x, y, z)]
Ty = [V,(x, y, z)]
Tx = [U, (x', y', 0)] + Uz * ([N,P] / Nz) - [U,C]
Ty = [V, (x', y', 0)] + Vz * ([N,P] / Nz) - [V,C]
Let n = The starting point number.
Let (Txn, Tyn) = Texture point corresponding to point n in 3D polygon.
Let (xn', yn') = Screen coordinates of 3D polygon point n.
Let (xn, yn, zn) = 3D polygon coordinates of point n.
Let u_off = The Uz * ([N,P] / Nz) - [U,C] constant offset.
Let v_off = The Vz * ([N,P] / Nz) - [V,C] constant offset.
u_off = [U, (x', y', 0)] - Txn
v_off = [V, (x', y', 0)] - Tyn
Tx = [U,(x', y', d)] - u_off Ty = [V,(x', y', d)] - v_off