# Drawback of painters algorithm:

We know that to scan convert any polygon first we need to pass any 4 tests of Painter's algorithm.

Suppose I have two polygon S1 and S2, which order is S1->S2.we see that all 4 tests are failed. See the below image where projections on the xy plane is overlapping. So we need reorder the polygons and tests further whether it will be passed any of the 4 tests or not. After reordering (S2->S1)if we see again 4 tests are failing and xy projection overlapping, it may go into infinite loop. But book says this type of positioned polygon(S1, S2) never go into infinite loop.

My question is where I did mistaken to understand the things? Why after reordering S1,S2 never go into infinite loop if there may be projection overlapping?

Note:Reference 1 ,Reference 2

• From your recent series of questions, I get the impression that the book you're trying to learn from might just be not very good, or at least, not a good fit for your needs and learning style. I'd recommend trying to learn from a different source. Dec 11, 2021 at 15:58
• @Dmgregory I am not only following book, I am following different videos etc. But some critical concept not available book, videos. That why I posting this questions. Dec 11, 2021 at 16:05

But book says this type of positioned polygon(S1, S2) never go into infinite loop.

Does it? The sample you've shown us says:

It is possible for the algorithm just outlined to get into an infinite loop if one or more surfaces alternately obscure each other, as in Figure 11. In such situations, the algorithm would continually rearrange the ordering of the overlapping surfaces.

To avoid such loops, we can flag any surface that has been reordered to a farther depth position so that it cannot be moved again. If an attempt is made to switch the surface a second time, we divide it into two parts to eliminate the cyclic overlap. The original surface is then replaced by the two new surfaces, and we continue processing as before.

So, it seems to me that the book specifically calls out that infinite loops are a risk when you have polygons that fail the first test, as shown in the diagram (and all other tests). And it also tells you what to do about it.

If the book elsewhere claims that this infinite loop cannot occur for a specific case, that has not been shown in the excerpts that you've included in your question.

• see this where infinite loop Dec 11, 2021 at 16:14
• you just tell when first all test fails, then we perform reordering, if after reordering again all tests fails of the image posted in question, then what should I do? Dec 11, 2021 at 16:17
• my posted image in question not alternately obscure, so why infinite loop could have been occurring? Please reply, I am waiting for your reply. Dec 11, 2021 at 16:42
• The image in your question might or might not show alternate obscuring surfaces. We cannot tell from this image alone. It could be that although S1 and S2 overlap in screen space, one polygon sits entirely behind the other in depth . Or it could be that S1 and S2 intersect, with say the left corner of S2 poking through the front of S1. If all tests fail a second time then you should follow the directions given in the book: divide the previously re-ordered polygon into two parts. (You could use the other polygon as a cutting plane to ensure one part is fully in front and one fully behind) Dec 11, 2021 at 16:51
• division of surface is recursive process? Dec 15, 2021 at 5:43