Game Development Reference
Compact FB/two channels
Resolved FB/three channels
Figure 4.2. Overview of our compact encoding format. The framebuffer is stored in two
channels. The first channel stores the luminance of each pixel, while the second channel
stores the chrominance interleaved in a checkerboard pattern. A simple and ecient
either the chroma orange (C o ) or the chroma green (C g ) of the input fragment,
interleaved in a checkerboard pattern, as illustrated in Figure 4.2. This particular
arrangement corresponds to a luminance-to-chrominance ratio of 2:1 and provides
a 3:2 compression ratio, since two color channels are used instead of three. The
same luminance-to-chrominance ratio is used by many video compression codecs
and is referred as 4:2:2 in the literature, but the details on how the samples are
produced and stored are different.
In order to create the compressed framebuffer on the GPU, applications can
either request a render buffer with just two color channels, such as GL RG16F or
any similar format exposed by graphics APIs, or use a more traditional format
with four color channels and use the free channels to store additional data. The
latter case can be particularly useful in deferred rendering pipelines.
The fragments produced by the rasterization phase of the rendering pipeline
should be directly emitted in the correct interleaved format. This can be easily
done with the code snippet of Listing 4.1. In this code the fragment color is first
//Convert the output color to YCoCg space.
vec3 YCoCg = RGB2YCoCg(finalColor.rgb);
//Store the YCo and YCg in a checkerboard pattern.
ivec2 crd = gl_FragCoord.xy;
bool isBlack = ((crd.x&1)==(crd.y&1));
Listing 4.1. Code snippet in GLSL to convert the output color in our compact inter-
leaved format. The RGB2YCoCg function implements Equation (4.1).