 Hello friends, myself Darshan Pandit, Assistant Professor, Department of Computer Science and Engineering from Walton Institute of Technology, Solapur. So, here we are going to discuss about Painter's Algorithm. So, the learning outcome is like at the end of the session student will be able to identify visible lines and surfaces through Painter's Algorithm. So, in this we will see what is Painter's Algorithm and what are the steps involved in Painter's Algorithm. So, Painter's Algorithm is developed by Newell and Sancha. So, the basic idea of Painter's Algorithm is to paint the polygon into the frame buffering in the order of decreasing distance from the view point. So, it is also called as depth shot algorithm. The algorithm gets its name from the manner in which oil painting is created. So, in oil painting the artist begins with the background, he then adds the most distant object and then the nearer object and so on. So, there is no need to erase the portion of background. The artist simply paints on top of them and the new paint covers the old so that the newest layer of paint is visible. So, this process involves basic functions that is sorting of polygon in the order of decreasing depth, resolving an ambiguity that is caused due to polygons that is when polygons z extent overlap then we need to split the polygon into two different polygons. And in step 3 scan conversion of polygon in the order starting with polygons greatest depth. So, in this diagram you can see so on the background in figure A first circle is painted. So, on the top of circle a triangle is painted and this triangle covers some part of circle ok. So, here we do not need to erase the circle and paint the triangle. So, directly on top of the circle triangle is painted. So, again in figure C a square is painted on top of circle and triangle ok. So, this is how the painter's algorithm works. So, using similar technique we first sort the polygons according to their distance from the view point ok. So, the intensity value of farthest polygon are then entered into the frame buffer. So, here taking each polygon is succeeding polygon in turn with the decreasing depth order ok. So, polygon intensities are painted on the frame buffer over the intensity of previously processed polygons. So, this process is continued as long as there is no any overlap between two polygons. So, if depth overlap is detected by any point in the sorted list we have to make some additional comparison to determine whether any of the polygon should be reordered ok. So, in our example we consider two polygons P and Q. So, that we can check whether any polygon Q do not obscure polygon P that is polygon Q do not overlap polygon P. So, this can be done by performing following test. So, test 1 the z extent of P and Q do not overlap that is z Q is less than z P min. Second the y extent of P and Q do not overlap ok. So, this is given in figure B. In step 3 the x extent of polygon P and polygon Q do not overlap. Test 4 polygon P lying entirely on opposite side of Q's plane from the viewport and test 5 polygon Q lying entirely on same side of P's plane as the viewport and test 6 the projection of polygon P and Q on to x y screen do not overlap. So, in the diagram you can see. So, figure A shows where the z extent of P and Q do not overlap that is z Q less than z P min. So, you can also see how the objects are displayed on the display screen with the screen display of Q and P. And also you can see the screen display of Q and P ok in figure B where the y extent of P and Q do not overlap. So, in figure C you can see an overlap where polygon P entirely lie on opposite side of Q's plane from the viewport or you can see the z extent of P and Q where polygon Q lying entirely on same side of P's plane as a viewport ok. So, you can consider any of these cases by identifying the surface. So, if all this 5 test that is from 1 to 5 fail we assume that the movement P actually obscure Q and therefore, whether Q can be scan converted before P. So, here we have to repeat test 4 and test 5 for polygon Q. If this test also fail then we can say that there is no order in which polygon P and polygon Q can be scan converted correctly. And we have to split either P or Q into 2 polygons. So, the idea behind splitting is that splitted polygon may not obscure another polygon. So, this is how the algorithm works. So, there are basically 3 steps given in this algorithm. So, the first step is like sort the polygon in the order of decreasing depth. In step 2, we have to determine all polygon Q preceding polygon P in the polygon list where z extent overlap that of P ok. That is we need to determine all the polygons whose z extent overlap ok. So, if z extent overlap that is if 2 polygons z extent overlap then we need to perform the test 2 to test 6 ok. So, if z extent do not overlap then directly we can display the polygon on the viewport that is directly we can paint those polygon ok. So, the problem arises when the z extent of 2 polygons overlap then in step 3 we need to perform test 2 to test 6 for each polygon Q ok. That is if overlap occurs. After that if every Q passes the test then scan convert the polygon P scan convert the polygon P is nothing but we need to draw polygon P on to the viewport ok. 3 B if test fails for some Q then swap P and Q in the list and make indication that Q is swapped. If Q has entirely being swapped use the plane containing polygon P to divide polygon Q into 2 polygons that is we are separating polygon Q into 2 polygons such that Q1 and Q2 and replace Q with Q1 and Q2 and again we have to repeat the step 3 that is again we have to check test 2 to test 6 for polygon Q ok. So, this is how the painter's algorithm works and useful for identifying the objects that is which lie behind and which is at the front ok. So, this can be easily identified with the help of painter's algorithm. So, here you can pause the video and answer the question select the correct option. So, the painter's algorithm paints options are A object from back to front, option B object from front to back, see nearer object and none of these options are correct. So, option A is the correct answer as polygons at more distant from the viewport are painted first. So, these are the references which I have used to create this video. Thank you.