A Parallel Projection Texture Mapping Technique

equations last updated: 6-17-1998
last updated: 6-17-1998

The difference between parallel and perspective projection.

Our eyes see everything using perspective projection. One common feature of perspective projection is a horizon. This is where everything looks small at a distance, but large close up. Another type of projection is parallel projection. This projection most closely resembles seeing a far away object through a telescope. This causes the rays of light that enter the eye to be nearly parallel, and the effects of depth are lost. Isometric game engines use parallel projection.


Deriving parallel projection equations from perspective projection equations.

Since we know that an object far away is displayed with nearly parallel projection, one of our assumptions can be that the z coordinates approach infinity. This will also make our object appear extremely small, so we also scale the size of the image to approach the same infinite size of z. This is done by making d equal to the offset of the z coordinates.

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

Using the general perspective projection formula for texture mapping derived in A General Texture Mapping Technique , we have found the equations that allow us to find a position on a texture image given screen coordinates. The only part of the equation that varies with screen coordinates is [U,(x',y',0)] and [V,(x',y',0)]; the rest stays constant.

Applying the parallel projection equations.

Applying the equations for parallel projection follows that of perspective projection described in Applying the Texture Mapping Technique. The only difference is that the equations are simpler and we can avoid division.
The section on "Describing the textured 3D polygon" is exactly the same for parallel projection as it is for perspective projection. The setup for drawing the polygon is greatly reduced in complexity, and we don't need to store as much information ahead of time. There is only the offset constant that needs to be worried about. The vectors, u, v, and n, need to be rotated before the calculation exactly like in the perspective projection case.

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

Using the constants to find the pixel in the texture image is the same as the perspective projection case, except for the difference in formulae. Comparing the parallel and perspective projection techniques, it should be noted that parallel projection does not require as much setup before drawing, and also requires less math to find each pixel. Because the equation that finds the pixel is first order, and linear, special techniques similar to those used in Bresenham's line algorithm.

Tx = [U,(x', y', d)] - u_off
Ty = [V,(x', y', d)] - v_off

joshuacantrell@yahoo.com

(My Home Page) - (My Personal Page) - (My Computer Science Page) - (My Resume)