An OGSS Implementation

Ordered Grid Super-sampling (OGSS) is a technique that can be implemented on almost all 3D accelerators, given that they support rendering to an off-screen buffer. An off-screen buffer has room to store the frame 's pixel colors, as well as the Z and Stencil values. However, it differs from a conventional front-or back-buffer in that it is never displayed directly on screen.

As was explained before, the OGSS method uses a regularly-patterned ordered grid of sub-samples for each pixel. Below we detail a step-by-step description of how OGSS anti-aliasing can be performed on today 's 3D hardware.

1. The game engine creates the 3D environment using a 3D API like Direct3D or OpenGL. Both of these APIs use triangles as their basic building block to create 3D objects. Each triangle has coordinates in 3D space. These coordinates are transmitted,transformed and lit , through the API via the 3D card 's specific driver. We'll assume in this simple example that our screen has a resolution of 10-by-10 pixels, and that we have a triangle with vertices at positions (5,5), (10,10) and (10,0) - forming a triangle on the right hand side of the screen.

2. The coordinates supplied by the API target a specific screen resolution. When the vertices are transformed and lit, they are provided screen-space coordinates (unlike the world-coordinates used by the 3D application). These coordinates are thus linked to the final screen resolution. To reach our anti-aliasing goal, we need to up-sample these coordinates by at least a factor of two in both the horizontal and vertical direction to create a sufficient number of sub-samples for effective anti-aliasing. This up-sampling is a simple multiplication by two of all screen coordinates. Up-sampling by a factor of two increases the screen resolution of our example to 20-by-20 (10 multiplied by 2). Our vertex positions will be up-sampled to (10,10), (20,20) and (20,0). Notice that the vertices and thus the triangle remain at the same relative position in screen-space.

3. The result of the previous operation is that all geometry is zoomed by a factor of two in both the horizontal and vertical directions. Simply put, everything is twice as big. We thus have four times the number of pixels drawn as compared to no up-sampling being per-formed. Our original screen of 10-by-10 pixels is now 20-by-20 pixels.

4. We render all the up-sampled geometry of this frame as we normally would, but to an off-screen (invisible) buffer. The reason for using an off-screen buffer is that our goal is to have a 10-by-10 anti-aliased image, not a 20-by-20 up-sampled one. Note that our example assumes only one triangle. A real world application, of course, has many more.

5. When the whole scene of this frame is rendered, we have a high-resolution picture of the 3D world. We now need to down-sample this high-resolution picture into an anti-aliased lower resolution version. We thus need to go from 20-by-20 "super-sampled "(double resolution) image to a 10-by-10 anti-aliased image. This down-sampling is achieved by mixing pixel colors together in groups of two-by-two. Essentially, we take the color values of four neighboring pixels (square shaped),add them together and then divide by a factor of four. This means that the resulting color is an equal mix of the colors of the four high-resolution pixels. These four pixels in the high-resolution image are really the sub-samples of the anti-aliased pixels. Combined together, these sub-samples form a final anti-aliased pixel for the rendered image. By sampling at a higher resolution and then filtering down using an averaging filter, the high frequency components are smoothed out, which reduces the aliasing considerably. For a simple example, assume our scene contains dark bars (0%) on a bright background (100%),arranged in the vertical direction (striped effect)with a height of one sub-sample. The sub-sample would contain two dark and two bright sub-samples. The filtered down result of this is a half bright, half dark pixel. So the high frequency effect (0%and 100%alternating) causing aliasing is reduced to a continuous 50% blend.

6.The end result is of this process is again a 10-by-10 image,but anti-aliased via an OGSS super-sampling technique. We will discuss another important aspect of this process -the quality of anti-aliasing -later in the article.

A schematic overview of this OGSS technique can be seen in Figure 4 below:




This practical implementation achieves Ordered Grid Super-Sampling by up-sampling the scene by a factor of 2, both horizontally and vertically. By increasing the horizontal and vertical resolution during the up-sampling, extra sample positions are introduced in an ordered grid shape. These sub-samples are located inside the original pixel, as illustrated by Figure 3a.

In our example, we used an up-sampling rate of two in both the horizontal and the vertical direction. Nothing prevents an implementation where other up-sampling ratios are used, such as four or even more. Usually this factor is used to identify the type of OGSS. Thus, the terms 2X OGSS and 4X OGSS are often used to describe the number of sub-samples used in an OGSS implementation. Sometimes the number of sub-samples is identified by the word "tap", thus leading to the names 4-tap or 16-tap OGSS. So with a 16-tap OGSS, we have 4 sub-samples in the vertical and 4 in the horizontal. A point worth mentioning is that the names Full-Scene Anti-aliasing and Full-Screen Anti-Aliasing are often used out of place. Generally, this term is used to represent OGSS, but what it truly means is that an entire image undergoes an anti-aliasing process (whether it be OGSS or RGSS or some other technique for anti-aliasing). However, it is important that we note what type of anti-aliasing is implemented in hardware because it has an impact on quality, as will shortly be investigated.

Finally, it should be noted that this implementation of OGSS using existing 3D hardware suffers from potential incompatibility with applications that use Linear Frame Buffer access. Linear Frame Buffer access is a technique where an application writes values directly into the buffers (Frame and/or Z/Stencil).The problem with this is that internally the render target is up-sampled to a higher resolution. The application is not aware of this and, as a result, the Linear Frame Buffer access goes wrong. A simple example will illustrate the point. Assume a game wants to use Linear Frame Buffering to overlay the screen with a cockpit image. This overlay image has the resolution of the final image, not of the up-sampled, internal, higher-resolution off-screen buffer. As a result, an overlay with the size of the final image is written to the up-sampled buffer (so 1/4th the correct size), which of course results in an incorrect result. The overlay would end up occupying only 1/4th of the proper dimensions in the final anti-aliased screen image. Applications that use Linear Frame Buffer access, therefore, must be handled with special care. The problem must be managed with special tricks at the driver level, as solutions are rarely supported in hardware. Needless to say, this has a nasty performance impact but without this special handling, vulnerable applications will show an incorrect end result.