I am new to 2D texturing and I am wrestling with a combination of distorting the shape of the texture and filtering. For now, my texture is a test pattern consisting of vertical stripes alternating black/white. (Later it will contain live image data.) The contiguous quad strip I am mapping the texture to is drawn with polygons side-by-side in the X direction, with the top vertex pairs of each polygon closer together than the bottom pairs. In the limiting case, all the top vertices are the same, and the display list then draws a pie-shaped sector with the point vertex at the top. The texture pattern is correctly squeezed so that all the stripes originate at the top, and they fan out towards the bottom. This all works.
My problem is that the simple linear filtering I have chosen – as well as a lot of experimental variations – does not produce the expected image smoothing in the lateral X direction, only in the radial direction. In the lateral direction, I can see the boundaries of polygons where I expected to see smooth variation in greyscale.
This problem is clearly associated with the “squeezing” action of the top vertices: the more I spread them apart, approaching rectangles, the smoother the lateral transitions between polygons, until the smoothing reaches the same excellent filtering I see in the axial (vertical Y) direction.
My texture dimensions are 128 lateral by 512 vertical, but I am mapping only a 121x300 region of the texture with my texture coordinates. There are, accordingly, exactly 121 little sector polygons in my quad strip.
My filter settings are as follows.
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
I have tried mip mapping, which improves the look of the top of the image when I tilt it about the X axis so that the apex is farther away, but does not make any difference when viewed en face. I have also tried anisotropic filtering at the maximum level my hardware supports (16.0), with no visible effect.
Here are some images to illustrate the problem.
The first image shows my test pattern, with alternating black/white radial spokes, and no filtering. This renders as expected.
The next image shows my test pattern, again with alternating black/white radial spokes, and linear filtering. The filtering is good at the bottom, and gets worse as you go up towards the middle of the image.
The next one is a zoom (increased scale) of a region near the middle of the image, showing the blocky lateral filtering of spokes.
The next is a zoom of a region near the bottom middle of the image, showing desired lateral filtering across the spokes. Would that I could get this effect everywhere.
The last image is the same format, but the test pattern is changed to a random number generator. Again a zoom of the middle of the image. Note the nice filtering in the axial direction as the data changes, but in the lateral direction, there are borders at the boudaries of the spokes.
thanks in advance,