PDA

View Full Version : Blending projected textures on radeon card



penry
03-10-2001, 04:59 PM
I've been experimenting with blending projected textures to create reflection/refraction effects and everything worked ok until I upgraded from a Voodoo3 card to a Radeon card and suddenly I'm getting z buffer artifacts. The problem seems to be related to using glTexCoord3f, as shown below. It also works OK on my laptop, which doesn't have hardware acceleration.
BTW, near and far planes are set 0.1 & 100.0, which shouldn't be a problem.

The code is like this

glBindTexture(GL_TEXTURE_2D, texture[0]);
for (j = 0; j < WATER_ROWS; j++) {
glBegin(GL_TRIANGLE_STRIP);
for (i = 0; i <= WATER_COLS; i++) {
glTexCoord2f(s(i), t(j));
glVertex3f(x(i), y(i,j), z(j));
glTexCoord2f(s(i), t(j+1));
glVertex3f(x(i), y(i,j+1), z(j+1));
}
glEnd();
}

glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 0.40f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBindTexture(GL_TEXTURE_2D, texture[1]);
LoadTextureProjectionMatrix();
for (j = 0; j < WATER_ROWS; j++) {
glBegin(GL_TRIANGLE_STRIP);
for (i = 0; i <= WATER_COLS; i++) {
glTexCoord3f(x(i), 0.0, z(j));
glVertex3f(x(i), y(i,j), z(j));
glTexCoord3f(x(i), 0.0, z(j+1));
glVertex3f(x(i), y(i,j+1), z(j+1));
}
glEnd();
}
ClearTextureProjectionMatrix();