Hi there pros, I hope this hasn't been asked before, I searched for any ways of saying z-fighting I could think of and got nothing anyways I am making a basic rendering type deal for my first program (we prolly all do ) and I am having a few difficulties with the z-fighting of my polygons. basically I sort the table of polygons (sides of a rectangle) based on their center position's offset from the center of the rectangle, this seems to work fine except when I translate the cube it stops working... a link to the script is here: http://dl.dropbox.com/u/84093549/Links/Render.love
drag the mouse with no buttons pressed to move the shape, try rotating it in its current position and then moving it and rotating it again... only certain sides have issues
well all I do is sort the table so the back faces are at the beginning of the table and the front ones at the end (I sort it by the z and x cds to determine what's in front), then I render them one after the other and the front ones are drawn over the back ones
When you put the 6 faces into your table, you put them in back to front with no rotations, and then rely on the painter's algorithm. Then, when you rotate them around, the original back surface in put in front of the original front surface (because you rotated it around to see the back of it), but then the draw order is the backface, then the other faces, and then the front face. The "Z" fighting is because your algorithm does nothing to render the faces in the correct order. Jasoco's solution is probably the best, i.e., don't rely on Painter's Algorithm. Check to see what direction the surface is facing, and only draw the ones that are facing you.