What causes this wierd OpenGL anomaly?
See?
Its supposed to be a box with a yellow lid, but the lid, and some of the other faces too, exhibit this wierdness, where you can see some triangle trying to be drawn underneath it or something. I know for a fact that I am not drawing any polygons except for the 6 rectangles that make up the box. Where do the triangles come from?
Edit: oops I forgot to close a quote and it messed up the whole gdnet page. SOrry!
Edit: converted to jpg
[edited by - AndreTheGiant on January 13, 2004 3:19:16 PM]
Z-fighting. Take off the top rectangle from the box and there''ll be no problem.
Also, it may be better not to post BMPs. . . Convert it to some compressed format like JPEG (lossy) or PNG (lossless). Irfanview is a great program for this:
www.irfanview.com
Also, it may be better not to post BMPs. . . Convert it to some compressed format like JPEG (lossy) or PNG (lossless). Irfanview is a great program for this:
www.irfanview.com
Thanks for the advice
Z-fighting eh? Ill have to look that up.
BUt it seems rediculous to me that I cant have a lid on my box! Ill take it off to see if that helps, but are you seriously telling me I cant have a solid box in my app? I have to Take the lid off? that is madness!
Someone please clarify or confirm.
Thanks.
quote:
Z-fighting. Take off the top rectangle from the box and there''ll be no problem.
Also, it may be better not to post BMPs. . . Convert it to some compressed format like JPEG (lossy) or PNG (lossless). Irfanview is a great program for this:
Z-fighting eh? Ill have to look that up.
BUt it seems rediculous to me that I cant have a lid on my box! Ill take it off to see if that helps, but are you seriously telling me I cant have a solid box in my app? I have to Take the lid off? that is madness!
Someone please clarify or confirm.
Thanks.
Blue box, yellow lid, yeah? Take the top side off the blue box. Or move the lid away from the box a small amount. The lid and the top side of the box occupy the same space and so OpenGL doesn''t know what to draw.
[teamonkey]
[teamonkey]
It looks like you have a solid cube (6 sides) of all blue and then you draw a second poly on top to make the lid. I can''t explain it otherwise.
Z-fighting occurs when two different faces try to occupy the same or nearly the same planar space. Since there isn''t enough difference between different z values for the two planes when projected to accurately distinguish between them (due to precision limits of float/double types, round-off errors, etc.) this causes parts of one plane to have a lower z in one location, higher z in another, and so the planes mix strangely. When you have a plane that needs to be displayed coplanar with another (sometimes called decaling in certain applications) then you need to offset the top plane by enough space from the lower plane to eliminate the z-fighting.
How much you need to offset really depends on the precision of your z-buffer as well as on the world space covered by your near and far clipping regions. A large discrepancy between minimum and maximum z in the visible region leaves less of the float precision bits available for small distances, so your offset may need to be larger than if the relative space covered is small. It''s largely an area for experimentation, and depends upon your projection setup.
Josh
vertexnormal AT linuxmail DOT org
Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.
How much you need to offset really depends on the precision of your z-buffer as well as on the world space covered by your near and far clipping regions. A large discrepancy between minimum and maximum z in the visible region leaves less of the float precision bits available for small distances, so your offset may need to be larger than if the relative space covered is small. It''s largely an area for experimentation, and depends upon your projection setup.
Josh
vertexnormal AT linuxmail DOT org
Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.
Thanks for all your help everyone. I fixed the problem, though it had nothing to do with z-fighting. I was scared for a minute there when VN said that maybe my polys are too close together. At their closest point, they are like 128 apart, and if that was too close, then I was going to be in trouble because I had planned on making them a lot closer than that!
Anyway thanks a lot. I learned a lot guys.
Anyway thanks a lot. I learned a lot guys.
Due to where I was getting my input from, the order of the vertices for each polygon making up the cube were essentially random. I had to write code to ensure that the polygon vertices were given in clockwise order to make the wired triangles go away.
Its good to know about z-fighting though, because I never head of it before and it might yet come up in my project.
Its good to know about z-fighting though, because I never head of it before and it might yet come up in my project.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement