PDA

View Full Version : texture problem--transition layers on the boundary



sguTiger
06-09-2009, 08:31 PM
Hi,
I am using 4*4 texuture. The upper 3*3 texels are pure red(RGB:(1,0,0)), the others are pure green(RGB:(0,1,0)). I am using the following setting:
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
And then I draw a square and mapped it to the texture,
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(0.0, 0.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 0.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0,0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(0.0, 1.0, 0.0);
glEnd();
But I saw a transtion layer on the boundaries. I can understand the transition layer in the interface of the two colors. But Why there are transtion layers near the boundaries? What should I do if I want to keep the transition layer on the interface, but not on the boundary?

ZbuffeR
06-10-2009, 12:54 AM
GL_CLAMP interpolates to 50% of the border color (black by default).
To avoid this, use GL_CLAMP_TO_EDGE.