Quad texture distortion?
I'm drawing polygons in an orthogonal projection, but I'm experiencing some texture distortion when I try to draw a quadrilateral that isn't a parallelogram. For example: here's my test texture:
Now here's what happens when I try to draw this texture as a trapezoid, using two triangles:
I can see what's happening. When the first primitive is drawn, it doesn't know about the other one; so it just assumes that it's part of a parallelogram, and stretches the texture accordingly. I'm drawing the quad as a triangle strip, but it still distorts.
My vector format is D3DFVF_XYZ | D3DFVF_TEX1. There must be some way of making the texture stretch according to each vertex of the quad. Do I need to add anything to my vertex format? Or is there some other special way of rendering the quad?
Thanks!
You need to use perspective correct texture mapping to solve this problem, which basically means setting the correct Z value for each vertex. Other than that, there is not much you can do, although you can try subdividing your quadrilateral: for instance, take the middle point and render the quadrilateral as four triangles instead of two, or divide each edge by two to get six triangles.
There *is* a fix for this. I saw a paper on it once, which I can't seem to find right now. It involved always using the W coordinate so that a texture coordinate divide was happening per pixel instead of being baked into the UVs of each vertex.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement