Texture artefact (noob)
Hi,
I have just started programming some opengl and am applying textures to a cube. When I apply a different texture to each of the faces of the box (quads) I see a single pixel line (dark in light regions, light in dark ones) following the polygon join. This doesn''t happen if I use the same texture for all faces of the box (it is not symmetrical, btw) or if I only use coloured faces.
This did sound (a bit) like the Z-fighting in the FAQ but I have already tried that solution to no avail
Can anyone point me in the right direction to eliminating these lines, or even something to google for - I am not sure what the name for this is!
Thanks.
Fireking, that looks to me like you are having normal computation issues. When you compute the normals, I would guess that you read some memory that is out of bounds giving you garbage data. Try drawing the normals, and see what they look like. Kennith, is that what your problem looks like too?
Are you using:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
?
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
?
No, it doesn''t really look like fireking''s problem - the textures match at the boundary but imagine a bright line, one pixel thick, running along the boundary - fireking''s picture seems to show a gradual colour change on one side of the join.
I have tried
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_[ST], GL_CLAMP)
(not GL_CLAMP_TO_EDGE though, so I''ll try this when I get home) but this didn''t seem to help (as it is a problem only where different textures are being used, I would have thought that I would see the same thing with a repeating texture?).
I see there are GL_CLAMP_TO_BORDER_EXT and GL_CLAMP_TO_EDGE_EXT options (in OpenGL 1.1 reference) - are these no longer EXT beyond 1.1?
I have also tried using glEdgeFlag( GL_FALSE ) to prevent drawing of edges (as in TheRedBook Ch.2). Obviously there is a certain amount of experimentation going on at this stage
I have tried
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_[ST], GL_CLAMP)
(not GL_CLAMP_TO_EDGE though, so I''ll try this when I get home) but this didn''t seem to help (as it is a problem only where different textures are being used, I would have thought that I would see the same thing with a repeating texture?).
I see there are GL_CLAMP_TO_BORDER_EXT and GL_CLAMP_TO_EDGE_EXT options (in OpenGL 1.1 reference) - are these no longer EXT beyond 1.1?
I have also tried using glEdgeFlag( GL_FALSE ) to prevent drawing of edges (as in TheRedBook Ch.2). Obviously there is a certain amount of experimentation going on at this stage
quote:Original post by KennithTheMenith
I have also tried using glEdgeFlag( GL_FALSE ) to prevent drawing of edges (as in TheRedBook Ch.2). Obviously there is a certain amount of experimentation going on at this stage
The edge flag is only used when drawing in wireframe mode, so thats almost certainly not your problem.
Try switching your texture for a really low resolution one, say 8x8. If the artifacts get worse then it''ll be a texture filtering problem. In which case a texture clamp mode or tinkering with the texture coordinates would help.
Assuming your texture coords for each side go from 0 to 1 to use the whole texture, try adding an offset to your texture coords:
Offset amount width, oW = 1/texture width
Offset amount height, oH = 1/texture height
(0,0) becomes (oW,oH), (1,1) becomes (1-oW, 1-oH) etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement