Buffer

This tool creates a buffer, extending the color at the edges regions filled in with useful data into empty space. It also crops edges and fills in an empty background with a solid color.

Images made from baking an object in a program such as xNormal, Blender, Maya, or 3DMax may have a clear or black with islands of color information. These islands are areas where model geometry is mapped to the UV image, the UV regions. The blank regions are unused space. The coloring of the islands differs based on what type of image it is. The Buffer tool uses the color on the edge of an island and extends it out into the transparent or black pixels.

Buffering is usually done on mask images or baked normal maps, ambient occlusion maps, and height maps before they are used to create PBR images with the Mask and Overlay program.

Advanced Information

The areas with color on the original image are mapped to surfaces of the model when a 3d model with its material attached is rendered. Before buffering, the edges of islands map to seams on the 3D model. The transparent or black areas don’t map to anything. Buffering extends color into the clear or black pixel areas, so your region isn’t directly surrounded by clear or black pixels. Buffering may seem a waste of time since those areas don’t map to anything on the model. Buffering does end up being necessary because of something called MIP Mapping.

When the camera is looking at an object from far away or at a sharp angle, Unity uses a process called MIP Mapping. When Unity performs MIP Mapping, it creates smaller versions of texture images to be used when less detail is needed. This technique has performance benefits. The problem is that averaging pixel values make smaller, less detailed versions of the texture. Often they average pixels inside a UV region with neighboring pixels outside the UV region. If the image isn’t adequately buffered, pixels inside the UV region are averaged with transparent or black pixels outside the region, giving erroneous data.

For baked decals, you don’t want to add a buffer. You can use to program with a buffer width of 0 to replace the background without buffering. Default background colors for normal, ambient occlusion, heightmaps are: [0.5, 0.5, 1, 1] for normal maps, [1, 1, 1, 1] for ambient occlusion maps, and [0.5, 0.5, 0.5, 1] for height maps.

Typically you wouldn’t need to buffer mask images, albedo, or metallic maps for a baked decal that will be used in Mask and Overlay to change the texture of small areas.

Note buffering cannot be done correctly if the model’s UV map packs UV regions with different textures too closely together. Make sure when you unwrap a model in programs such as Blender, Maya, 3D Max, you use a large enough buffer.

Parameters

Texture

This parameter is where you select your input texture that is going to be buffered.

Fill Color

This parameter allows you to select a color to replace any pixels with alpha = 0 after buffering is completed. The options are none, auto, and color. The “None” option does not replace any pixels, “Auto” replaces them with one of a few common background colors based on the values of pixels in the image that do not have alpha equal to 0. The automatic colors are white [1, 1, 1, 1], black [0, 0, 0, 1], gray [0.5, 0.5, 0.5, 1], and flat normal [0.5, 0.5, 1, 1]. The “Color” option lets you manually select a fill color.

Buffer into Clear

In my description above, I describe the areas with no data as clear or black, but what if your image intentionally contains black pixels as part of the actual image? When this option is turned on, black pixels are treated as part of the image, and only clear pixels are treated as empty space.

Buffer into Black

Black pixels are the same as clear for buffering.

Buffer Pixels

The number of pixels buffered out from an edge in each iteration.

+ and –

These buttons allow you to run multiple inputs at the same time.

Iterations

How many times the program starts over from the top-left pixel and runs through every pixel in the image running the buffering operation

Lower color limit

If the alpha value is less than this parameter, the pixel is treated as empty space

Crop pixels

Sometimes, the edges of an image come out crappy, and you don’t want to use them for the buffering. This option lets you remove edge pixels inward to the specified depth of pixels before buffering.