6.5 Video Filter

The gfx6.c sample program includes functions to make silhouette edge shapes and coverage values visible. To try this, change undef to define on line 37. When you do this, those places where the coverage value in the framebuffer is not 1 appear black, while everything else (where the coverage value = 1) is colored white.

Of course, when anti-aliasing is turned off, the coverage value in the frame buffer remains the default maximum value, so everything becomes white. Therefore, you need to confirm that line 27 is set to define.

Run the sample program in this state, and at the point in time when blending is finished you will see black lines for the parts that have not been anti-aliased yet (based on the coverage values in the framebuffer after interior edge anti-aliasing has been completed). This is the silhouette edge that is anti-aliased by the video filter.


Figure 6-6 Screen shots of gfx6.c sample program with __ANTI-ALIASING__ and __SHOW_COVERAGE__ defined.

The video filter performs anti-aliasing according to the following formula:

  Output = coverage value * pixel color + (1 - coverage value) * background color

The "pixel color" is the color of the framebuffer pixel that is now being anti-aliased. The "background color" is the color most different from the "pixel color," as selected from among the 3x5 array of pixels neighboring the pixel that is now being anti-aliased. This is used for smoothly blending the image.

In addition to making the coverage value visible, we will try an experiment defining a rendering mode. By defining __CVG_X_ALPHA__ on line 37 of gfx6.c, you add the CVG_X_ALPHA flag to the rendering mode. (To learn about what other flags can be used, see Chapter 15 of the Programming Manual.) When the CVG_X_ALPHA flag is specified, the coverage value and the alpha value are multiplied together, and the product is used for the coverage value and for the alpha value. As a result, when the coverage value is made visible, not only the silhouette but also the interior of the polygon is colored black.


Figure 6-7 Screen shots of sample program gfx6.c when __ANTI-ALIASING__, __SHOW_COVERAGE__ and __CVG_X_ALPHA__ are defined.