Dev:Ref/Release Notes/2.66/Image Transparency

提供: wiki
移動先: 案内検索

Blender 2.66: Image Transparency

The image pipeline has been refactored to handle transparency in images better. There are two alpha types for images that are useful for different purposes, and we now try to automatically do the right conversions and operations. Previously it was necessary to manually enable premultiplication options to get correct results.

The convention in Blender is now that byte precision buffers use straight alpha, and float precision images and buffers use premultiplied alpha storage.


Compositing & Rendering

For compositing and rendering, premultiplied alpha is the standard in Blender. Render layers will be premultiplied alpha, and images loaded into rendering or compositing will be converted to this.

Compositing

If some compositor operation should be done with straight alpha, the Alpha Convert node can be used. Typically this would be a color correction operation where it might give better results working on RGB channels without alpha. If alpha is converted to straight in the compositor, it should be converted back to premultiplied before the Composite Output node, otherwise some artifacts are possible.

Blender Render Alpha

In the Shading panel in the Render properties, the Alpha option changed. There are now two options:

  • Sky renders without alpha and produces an image where the world sky fills the background.
  • Transparent renders with an alpha channel and outputs premultiplied alpha pixels.

Compared to previous versions, the Straight alpha mode was removed. The reason for this is that we can now automatically save files with the right alpha mode, rather than the user having set it manually. The Sky alpha mode no longer outputs an alpha channel because this gives wrong results, saving such an image directly would give artifacts on antialiased edges.

Cycles Render Alpha

The Transparent option remains unchanged, when it is enabled a render with premultiplied alpha will be created. The difference now is that you no longer need to convert alpha types to save PNG and similar image files correctly, this should work automatically.

OpenGL Render Alpha

OpenGL render folows the same rules as Blender Internal render: if alpha mode is set to Sky no transparency will present in OpenGL render output, if Alpha Mode is set to Transparent, no color for transparent areas will present.

Quick texture painting will internally set alpha to transparent, so OpenGL render used for this tool will produce image with transparent background, which shouldn't affect on quick texture painting at all.

Image Files

Image alpha channel settings

For file saving, the image will be automatically converted to a suitable alpha type for the file format.

  • 8 bit formats (such as PNG) will be saved with straight alpha, float formats (such as OpenEXR, DPX) will use premultiplied alpha.
  • TIFF is handled a bit different here, as it supports both alpha types. 8 bit TIFF will be save with straight alpha, but 16 bit TIFF will be saved with premultiplied alpha. Appropriate information will be saved in TIFF metadata and it should always open fine in other software such as Gimp.

For file loading it's now possible to manually set which alpha mode the file used, although typically you can leave this to the default and get correct results.

Another alpha-related option was added to the image, which is called Use Alpha. If this option is disabled, the alpha channel from image will be ignored and image will be loaded fully opaque. This option replaces the Use Alpha for textures.


Theory

Straight Alpha

This is the alpha type used by paint programs such as Photoshop or Gimp, and used in common file formats like PNG, BMP or Targa. So, image textures or output for the web are usually straight alpha. RGBA color are stored as (R, G, B, A) channels, with the RGB channels unaffected by the alpha channels.

Premultiplied Alpha

Rendering will output premultiplied alpha images, and the OpenEXR file format uses this alpha type. So, intermediate files for rendering and compositing are often stored as premultiplied alpha. Compared to straight alpha, the colors could be considered to be stored as (R*A, G*A, B*A, A), with the alpha multiplied into the RGB channel.

This is the natural output of render engines, with the RGB channels representing the amount of light that comes toward the viewer, and alpha representing how much of the light from the background is blocked.

Conversion

Conversion between the two alpha types is not a simple operation and can involve data loss, as both alpha types can represent data that the other can not, though it is often subtle.

Straight alpha can be considered to be an RGB color image with a separate alpha mask. In areas where this mask is fully transparent, there can still be colors in the RGB channels. On conversion to premultiplied alpha this mask is 'applied' and the colors in such areas become black and are lost.

Premultiplied alpha on the other hand can represent renders that are both emitting light and letting through light from the background. For example a transparent fire render might be emitting light, but also letting through all light from objects behind it. On converting to straight alpha this effect is lost.