Channel Packing

From Resonite Wiki

Overview

Channel Packing is the practice of combining multiple grayscale images into one full color image by “packing” each grayscale image into a color channel of the resulting image. By doing this you can combine four grayscale textures into one, with one stored in the red, green, blue, and alpha channels respectively. This technique has been widely adopted as a way to cut down on the amount of textures a shader needs to sample as well as a way to save memory. To use the individual channels at runtime, the shader then splits the color image back into its respective grayscale components. It then reads the values in the image as a range from 0-255, where black represents 0 and white represents 255.

Usage

An image labled Metallic Map Channel Pack. There are four boxes on the left, each containing a grayscale image intended to be packed into one of the four color channels. They are labeled red, green, blue and alpha. They are connected by lines to a combined image where the four are combined into one image that is a combination of the four grayscale layers. Underneath the composite image is the following text Red - Metallic, Green - Ambient Occlusion or Height, B - Nothing, Alpha - Smoothness. In the bottom right this graphic is signed "Graphics by GreaterKibah"
Individual components of a metallic map

One of the most prominent examples of channel packing in Resonite is the metallic map, used by all the metallic shaders. There are two distinct metallic map packing standards used in Resonite. The first is used exclusively by the shader PBS_Metallic (the base version).

The layout for this map is as follows:

R - Metallic

G - Ambient Occlusion or Height

B - N/A

A - Smoothness

In this example three grayscale maps (metallic, ambient occlusion and smoothness) are packed together to result in the yellow-green texture. This texture can be assigned to both the occlusion map and metallic map. The occlusion map will read the information from the green channel to render ambient occlusion, and the metallic map will read the information from the red and alpha channels to generate metallic and smoothness respectively.

A screenshot of Resonite with a partially filled out PBS_Metallic shader in an inspector. A packed metallic map has been assigned to the occlusion and metallic map slots, and the material reflects these changes.
In game demonstration of a packed map being used for both the occlusion map and metallic map

It is important to note that this above packing standard is only used by the base PBS_Metallic shader. All other Metallic shaders and XiexeToonMaterial use the following packing standard:

R - Metallic, Ambient Occlusion or Height

G - N/A

B - N/A

A - Smoothness