Faze

12-27-2011, 05:25 AM

I'm working on a project where I'd like to render a strip of variable width, and texture it in such a way that the texture changes width (stretches/shrinks) along with the strip. The first way I could think of was to specify a triangle strip and set the texture coordinates at each vertex to (percent, 0) or (percent, 1), depending on whether the vertex is on the bottom or the top of the strip, and where percent is a variable from 0 .0 to 1.0 that represents how far along the strip the vertex is.

Unfortunately, I've run into a snag! Because the triangles in the strip are interpolating their "varying"s independently, each triangle ends up interpolating the texture coordinates in such a way that the texture warping is not continuous in each segment of the triangle strip. The attached image shows what I'm talking about. Within triangles (p0, p1, p3) and (p0, p3, p2), the texture is interpolated correctly, but in the quad (p0, p1, p2, p3), it's incorrect.

Anyone have any thoughts on how to do this the right way?

http://i.imgur.com/QRNFz.png

Unfortunately, I've run into a snag! Because the triangles in the strip are interpolating their "varying"s independently, each triangle ends up interpolating the texture coordinates in such a way that the texture warping is not continuous in each segment of the triangle strip. The attached image shows what I'm talking about. Within triangles (p0, p1, p3) and (p0, p3, p2), the texture is interpolated correctly, but in the quad (p0, p1, p2, p3), it's incorrect.

Anyone have any thoughts on how to do this the right way?

http://i.imgur.com/QRNFz.png