Property OutputAlphaMode
- Namespace
- PaintDotNet.Effects.Gpu
- Assembly
- PaintDotNet.Effects.Core.dll
OutputAlphaMode
Specifies the alpha mode of the output. This allows the effect infrastructure to automatically convert the effect's output to the alpha mode that is required for storage or rendering.
GpuEffectAlphaMode OutputAlphaMode { get; set; }
Property Value
Remarks
The default value is Premultiplied, which is almost always the
right choice because Direct2D operates natively in premultiplied alpha space. Some advanced
rendering scenarios may benefit from setting this to Straight,
such as when it is important to preserve color values for transparent pixels, or if you are
using a custom pixel shader that operates on straight alpha.
Usually it is best to use the default value (Premultiplied), and to then use PremultiplyEffect,
UnPremultiplyEffect, or ConvertAlphaEffect to convert the alpha
mode as required for each effect in the effect graph. This is important when different
effects or pixel shaders expect different alpha modes. Many effects have an AlphaMode property
which lets you specify the alpha mode for that effect's inputs and outputs. If an effect does
not specify anything about its alpha mode, you can assume it uses premultiplied alpha.
Paint.NET always uses straight alpha for storage, and Direct2D always uses premultiplied alpha
for rendering, blending, and compositing. Some Direct2D effects can operate on straight alpha
and will have documentation saying this, and/or they will have an AlphaMode property to configure
this. Premultiplied alpha makes many calculations easier, especially for blending and compositing,
but straight alpha is generally easier to reason about when doing other types of calculations
(such as in a custom pixel shader).
For more information on alpha formats and compositing, see: Alpha compositing (Wikipedia).