glTexCoord2f(0,0); glVertex3f(x1, y1, z1);
glTexCoord2f(0,0); glVertex3f(x2, y2, z2);
glTexCoord2f(0,0); glVertex3f(x3, y3, z3);
I originally thought that the color at texture coordinate (0,0) would be used to texture the entire image, but I guess that's not the case. On my texture, the pixel at (0,0) is black and yet when I texture a triangle with that coordinate, I get an ugly grey result. When the texture isn't the same for all vertices, everything looks fine.
Is this because the behavior in this case is generally undefined, or could there be something else wrong with my code?
Using the same texture coordinate for all vertices
I'm using a texture to implement fake phong shading, but I've come across a problem. I'll avoid the nitty gritty of what the phong shading is doing, since it is irrelevant to the what's going on.
This is an example of what is happening when certain conditions are met:
no idea
but Im going to give a wild guess
Could the texture Min and Mag filter modes be blending with neighboring pixels in some wierd way?
might try changing those settings around...
but Im going to give a wild guess
Could the texture Min and Mag filter modes be blending with neighboring pixels in some wierd way?
might try changing those settings around...
Yeah, that is what i think too.
Try
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
or
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
Try
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
or
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
Thanks guys, changing the texture parameters fixed it. There was no ambient or specular light set, only diffuse so I could keep things simple. I was using some old code and so my textures were set to repeat instead of clamp, which explains why I was getting the grey shade. Thanks again.
[Edited by - Kaezin on March 14, 2006 1:27:34 PM]
[Edited by - Kaezin on March 14, 2006 1:27:34 PM]
You probably dont have to set the texture-coordinates for every vert btw.
I think you can do the same thing like this (OpenGL will use the current value if no value is specified):
glTexCoord2f(0, 0);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y2, z2);
glVertex3f(x3, y3, z3);
I think you can do the same thing like this (OpenGL will use the current value if no value is specified):
glTexCoord2f(0, 0);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y2, z2);
glVertex3f(x3, y3, z3);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement