My textures begin to stretch whenever the polygon takes about 1/2 of screen space. The texcoords are correct. Screenshots, using a quad (tri strip) with a perlin noise texture: Everything is ok . Moving closer . And closer .
Apparently there’s still something wrong with the way you generate the texture coordinates. If you look closely you can see that the quad is divided into two triangles. The effect you see is a typical problem that results from using perspective correct texcoord interpolation instead of projective correct interpolation.
As I said the quad is made using triangle strips, but I’m 100% sure that the texcoords are correct (well, every thing is correct as long as the “camera” is not getting to close).
In theory, it will always look ok if your quad is almost parrallel to your viewing plane, because in that case the projective interpolation will be a perspective interpolation due to the constant q coordinate.
Exactly how do you generate the texture coordinates,?
Do you specify them explicitely by using texcoord2f or implicitly by using texgen?
An are you using fragment shaders? If so, do you perform texture lookups with tex or txp?
Originally posted by -NiCo-:
[b]Exactly how do you generate the texture coordinates,?
Do you specify them explicitely by using texcoord2f or implicitly by using texgen?
An are you using fragment shaders? If so, do you perform texture lookups with tex or txp?
N.[/b]
I’m using fragement programs, but my problem effects all shaded and unshaded polygons. I’m passing texcoords using VBO (glTexCoordPointer(2, GL_FLOAT, 0, SomeBufferOffset) , and they are correct. My terrain is using a fragement program and the textures are applied in the fragement program. The texture coordinates, however, are passed in an array and are interpolated wrongly, like on every other poly.
Looks like your texcoords are screw-up. If you want plain texture mapping set only S and T coords. Leave R and Q to 0.0.
Take a look in your fragment shader. Maybe you are change R and Q while doing some calculations, or because driver bug maybe fragment shader have some trash in R and Q.
As you can see from the figure at page 2 of http://developer.nvidia.com/object/Projective_Texture_Mapping.html
it’s possible that your rectangle isn’t a pure rectangle but a trapezoid.
This figure also does not make use of texture coordinate generation, but explicit coordinate definition. A small difference will result in a greater distortion at closer range and oblique angles
Originally posted by yooyo:
[b]Looks like your texcoords are screw-up. If you want plain texture mapping set only S and T coords. Leave R and Q to 0.0.
Take a look in your fragment shader. Maybe you are change R and Q while doing some calculations, or because driver bug maybe fragment shader have some trash in R and Q.
yooyo[/b]
R and Q are 0. I’m using 2d texture coordinates.
Originally posted by -NiCo-:
[b]As you can see from the figure at page 2 of http://developer.nvidia.com/object/Projective_Texture_Mapping.html
it’s possible that your rectangle isn’t a pure rectangle but a trapezoid.
This figure also does not make use of texture coordinate generation, but explicit coordinate definition. A small difference will result in a greater distortion at closer range and oblique angles
N.[/b]
I’m using 2 triangles so it shouldn’t make a difference.
In undistorted.bmp I drew a simple perfect rectangle using standard texture coordinates. The red color represents the s coordinate for texture lookup and green the t coordinate.
In undistorted.bmp I left the texture coordinates unchanged, but put one vertex at a different position such that it isn’t a rectangle anymore. Notice the diagonal line that appears.
It’s hard to find out the problem without having seen the full code.