Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In this picture (a perspective projection of an icosahedron), the scanline (red) intersects that vertex at the top. In an icosahedron each edge belongs to two triangles. From edge a, only one triangle is visible, the other one is in the back. Same for edge d. Also, in order to determine what color the current pixel should be, each polygon has a flag which can either be 'in' or 'out', depending upon where on the scanline we currently are. Flags are flipped according to the intersection of the scanline with the edges. Now, as we go from a to d (because all edges are intersected with the scanline at that vertex), this happens: the triangle behind triangle 1 and triangle 1 itself are set 'in', then 2 is set in and 1 is 'out', then 3 is set 'in', 2 is 'out' and finally 3 is 'out' and the one behind it is set 'in', which is not the desired behavior because we only need the triangles which are facing us to be set 'in', the rest should be 'out'. How do process the edges in the Active Edge List (a list of edges that are currently intersected by the scanline) so the right polys are set 'in'?

Also, I should mention that the edges are unique, which means there exists an array of edges in the data structure of the icosahedron which are pointed to by edge pointers in each of the triangles.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

(NB I've answered your related question on this topic as well. You may want to check that answer before reading this one.)

Once you've produced a z-buffer using linear interpolation, you will no longer be operating on the full edge list of your underlying projected geometry, but rather a reduced subset due to occlusion.

This subset is produced as follows:

You will produce the z-buffer itself which stores only depth; and in order to to maintain only unoccluded vertices you will at the same time build a separate, matching structure (same resolution) which contains no information except for (at the pertinent "pixel" locations) IDs of each projected vertex that was unoccluded after your z-buffer was built (that is, those that are actually visible in your z-buffer). It is this second buffer that you will now use to do in-out checks for scanline rasterisation.

HTH.

share|improve this answer
    
Thanks, that is exactly what I did, except instead of scanlining the whole screen at once, i scanline each individual polygon. –  Belgin Nov 28 '12 at 13:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.