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 .
Any help will be greatly appreciated.
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.
The figures at page 2 of the document at
illustrates this problem.
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?
I’m not using projected textures, just 2D textures.
Can you post the code where you draw the quad and specify the texcoords? Would make things a bit easier…
Originally posted by -NiCo-:
[b]Can you post the code where you draw the quad and specify the texcoords? Would make things a bit easier…
glTexCoordPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(0));
glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(8*sizeof(float)));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
Have you tested it without using VBO’s, just using
Does that make a difference? I’m not that experienced in using VBOs other than plain evrtex data.
Does it make a difference if you use GL_QUAD instead of GL_TRIANGLE STRIP?
This is a long shot, but did you change the TEXTURE_MATRIX somewhere?
If you’re using texcoord2f, using tex or txp shouldn’t make a difference in your fragment program, so that can’t be the problem
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
Just for kicks, add this line somewhere:
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
Those pics look like my first attempts at software texture mapping long ago.
I’m using 2 triangles so it shouldn’t make a difference.
This has got nothing to do with using triangles.
Take a look at http://www.esat.kuleuven.ac.be/~ncorneli/
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.
[quote]Originally posted by -NiCo-:
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, width, height, GL_RED, GL_UNSIGNED_BYTE, buffer);
VBO init code:
float *Data=new float;
delete  Data;
I’ve already posted the drawing code.