Hosting by Solid Eight Studios ,PhotoTangler Collage Maker

 U-V Overflow in Perspective Texture Mapping Question submitted by (30 June 1999) Return to The Archives
 I am using a common method of perspective texture mapping of defining a point and 2 direction vectors in world space (P, M, N) that define the texture's position and orientation. These are then translated into view space. I compute the orthogonal vectors A, B, C, and from these I use the projected 2D polygon screen coordinates to compute a, b, c (really 1/u, 1/v, and 1/z). To compute individual coordinates in texture space I take the reciprocal of c and multiply it by a and b to get u and v.This works great except at the edges of polygons where I often get u, v values that fall outside the texture boundaries. Apparently this is a common problem, since every example of this approach I have seen has been accompanied by some sort of hack to get around this. I have tried all of the common "fixes" but none have really been satisfactory. I have tried: Letting my textures wrap around (not an option for my particular implementation.) Clamping the u,v values at the ends of each scanline (time consuming plus makes the texture swim when the polygon is rotated.) Stretching the P, M, N vectors to cover an area in 3-space larger than the polygon (don't like this because of the storage and processing costs for extra vertexes. I also tried stretching P, M, N at runtime but have found no sure formula for how much to stretch.) Storing u, v coordinates at each polygon vertex (don't like the extra storage and processing during clipping and projection) Using sub-pixel precision in edge stepping when rasterizing polygons (I've read that taking care to rasterize polygon edges to always step on the center of pixels will fix the problem. I've found that this helps somewhat, but polygons at certain angles still exhibit the problem.) My question, then, what is the _RIGHT_ way to fix this?