Open In App

Computer Graphics – Scan Line Algorithm in 3D (Hidden Surface Removal)

This algorithm is based on the Image-space method and concept of coherence. As its name suggests itself Scan-line algorithm, so it processes one line at a time rather than processing one pixel(a point on raster display) at a time. The algorithm works as follows:

  1. Here each point at which the scan- line intersects the polygon surfaces are examined(processed) from left to right and in this process.
  2. The depth calculation (if there are overlapping surfaces found) is performed to identify the Hidden region(Visible surface) of the polygons which is nearer to the viewing plane.
  3. As soon as the visible surfaces(Hidden surfaces) are identified then the corresponding color-intensity values are updated into the refresh buffer(Frame buffer) if and only if the Flag of the corresponding surface is on.
  4. This algorithm works efficiently with one or more than one polygon surface and this algorithm is just an extension of the Scan line algorithm of Polygon filling.

Data Structure Used By Scan-Line Algorithm

Following data structure are used by the scan-line algorithm:



1. Edges list table(list): This list maintains the record of all the edges by storing their endpoint coordinates. The x-coordinate that we choose, whose Y-coordinate = Ymin.

Fig.1

2. Active edges table(list): This table contains all those edges of the polygon that are intersected(crossed) by the current scan-line. The edges are dropped into the table in a sorted manner(Increasing value of x). 



Fig.2

3. Polygon table(list): This list consists of: 

Fig.3

Let’s understand more by the example as shown in the below in Fig.4 figure:

Fig.4

Here, two overlapped polygons are given which are intersected by three Scan-lines S1, S2, S3 respectively. So, What happens if the Scan-line algorithm is applied in order to identify the Hidden surface(visible surface)?

1. First, examine the scanline(S1), whose, 

2. Then, process the scanline(S2), whose,

3. As Scanline(S3) is passing through the same portion from where Scanline(S2) is passing, S3 also has the same Active edge table(Aet) components as S2 has and no need to calculate the depth(S1) and depth(S2) again so S3 can take the advantage of the concept of Coherence.

Note: Coherence is a concept that takes advantage of regularities and uniformities possessed by a scene.

Scan-Line Algorithm

Article Tags :