Microsoft DirectX 8.0 (C++) |
In edge antialiasing, you render a scene, then re-render the convex silhouettes of the objects to antialias with lines. The system redraws those edges, blurring them to reduce artifacts.
First, find out if the Microsoft® Direct3D® device supports antialiasing by calling the IDirect3DDevice8::GetDeviceCaps method. If a device supports edge antialiasing, GetDeviceCaps sets the D3DPRASTERCAPS_ANTIALIASEDGES capability flag in the D3DCAPS8 structure to TRUE.
If the device supports antialiasing, set the D3DRS_EDGEANTIALIAS render state to TRUE, as shown in the code example below.
d3dDevice->SetRenderState( D3DRS_EDGEANTIALIAS, TRUE );
Now, redraw only the edges in the scene, using IDirect3DDevice8::DrawPrimitive and either the D3DPT_LINESTRIP or D3DPT_LINELIST primitive type. The behavior of edge antialiasing is undefined for primitives other than lines, so make sure to disable the feature by setting D3DRS_EDGEANTIALIAS to FALSE when antialiasing is complete.
Redrawing every edge in your scene can work without introducing major artifacts, but it can be computationally expensive. In addition, it can be difficult to determine which edges should be antialiased. The most important edges to redraw are those between areas of very different colors, for example, silhouette edges, or boundaries between very different materials. Antialiasing the edge between two polygons of roughly the same color has no effect, yet is still computationally expensive. For these reasons, if current hardware supports full-scene antialiasing, it is often preferred. For more information, see Full-scene Antialiasing.