I'm trying to add a simple repeating shaded gradient (think laminated layers) along the Z axis of arbitrary, highly tessellated objects (STL imports).
It's mostly working, but I get some really weird faces where the texture is not parallel to Z, but rotated and scaled differently. These faces are usually (possibly always) oriented vertically and some are quite large. I would think vertical faces would be the easiest to apply... so I'm currently stumped.
Here's the init:
glBindTexture(GL_TEXTURE_1D, _d->textures[0]);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //GL_DECAL);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, _d->sideImage.width(), 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, _d->sideImage.bits());
And in use:
glEnable(GL_TEXTURE_1D);
foreach(const STLTriangle& t, _model.triangles())
{
glBegin(GL_TRIANGLES);
glNormal3f(t.normal[0], t.normal[1], t.normal[2]);
glTexCoord1f(fmod(t.v[0][2],1.0)); glVertex3f(t.v[0][0],t.v[0][1],t.v[0][2]);
glTexCoord1f(fmod(t.v[1][2],1.0)); glVertex3f(t.v[1][0],t.v[1][1],t.v[1][2]);
glTexCoord1f(fmod(t.v[2][2],1.0)); glVertex3f(t.v[2][0],t.v[2][1],t.v[2][2]);
glEnd();
}
glDisable(GL_TEXTURE_1D);
Does anyone see something wrong in how I'm going about this?