Jump to content
  • Advertisement
Sign in to follow this  
CPPNick

Rendering algorithm - face sorting(C++)

This topic is 3620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I have been building a basic 3d rendering program. given a list of triangles, the program transforms them, converts them to an edge list, and displays filled 3d polygons on the screen. I HAVE gotten this to work, but not correctly, and DEFINATELY not quickly =/ I have a list of edges in the following format: struct EDGE { short int poly; // polygon's index float inv_slope; // inverse slope of the edge float x_int; // x intercept for the current line float p1[2]; // top point of the edge float p2[2]; // bottom point of the edge }; right now I have my active edge list sorted in order of ascending x intercept. I loop through the active edges for each scanline, and for each edge crossed, its active state is toggled to true or false in a list of booleans[one for each polygon] also, upon crossing an edge, I draw from the x intercept of the previous edge to the x intercept of the current edge using the texture from the topmost active polygon. my problem: in the case of a shared edge, two different polygons may share the same x intercept, causing my topmost routine to fail or return the incorrect polygon as topmost. in the case of a shared edge, how can you tell which polygon should be on top? worse yet, if two cubes were paralell and sitting snug up against each other, how would it be handled? edit: also if the corner or edge of a polygon were to come in contact with the middle of a face, this may also cause error. this question seems much to complicated anyways..I must be going about this entire process wrong... can anyone help me out? I am interested in how this kind of thing would be done in DirectX or the average 3d game. thanks =)

Share this post


Link to post
Share on other sites
Advertisement
Here are some pictures of the problem that I am trying to fix:

http://www.astro.virginia.edu/class/oconnell/astr511/idl_5.1_html/idl_127.gif
the edges in the above picture appear black, probably
because there are two topmost texels for those pixels.

http://java3d.j3d.org/faq/images/zbuffer_stripes.gif
the above website calls it "z-buffer tearing" but states that it is a precision related problem. but in the case of a shared edge or pixel then, how is this dealt with?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!