Bilinear interpolation for quadrilaterals was done by solving a quadratic formula for u and v, the texture coordinates, in relation to the x, y, z, coordinates. The same was done for triangular interpolation for triangle faces. I initially had some difficulty in solving the equation (quadratic). I tried using Maple, but in the end, my solution was correct while the Maple solution gave me a wrong answer, though it could have been division by zero errors. Triangular interpolation wasn't any problem because I used triangular interpolation previously for ray-triangle intersection to determine if a point was inside a triangle. The barycentric coordinates for a face map directly into texture space. In both cases, I determine the greatest absolute magnitude of the normal of the face, and do not calculate in that coordinate. I also have scaling factors and translation factors to move the texture about faces. Adding anti-aliasing for the next lab will be simple because of my implementation of sampling into texture space.
A cube with bilinear interpolation per face into the texture space. The cube has one normal per face.
Same cube, but the texture is clamped.
Same cube, but the texture is tiled.
A tetrahedron with triangular interpolation into the texture space. Notice how the texture is "warped" to conform to the interpolation along the two sides of a triangle face. The tetrahedron has interpolated normals across the face.
Same tetrahedron, but the texture is clamped.
Same tetrahedron, but the texture is tiled.