Alpha Blending and Alpha Testing(EN)
Выдержка из оригинальной справки. (NDL Gamebryo 1.1)
Отмечается, что режим с отключенным смешиванием дает большую скорость прорисовки.
Однако, как отмечалось, этот режим создает проблемы с прозрачность в ряде случаев.
Смешивание дает лучшее отображение и позволяет получить красивые эффекты, однако несколько понижает фпс.
Совмещение смешивания и тестирования, дает наилучший результат.
А также, указано, как изменять эти режимы посредством Нифскопа.
Gamebryo supports both alpha blending and alpha testing on textures that include alpha channels.
Neither alpha blending nor alpha testing is automatically used when an NiTexture with an alpha channel is loaded, however.
Because Gamebryo supports a wide range of alpha blending and alpha testing options, it cannot automatically set the alpha blending-mode based on the incoming texture.
In order to use alpha blending, a Gamebryo application must:
· Attach an NiAlphaProperty to the object that is to be blended.
· Enable alpha blending with NiAlphaProperty
· Ensure that the Base Map texture contains alpha data if the effect requires an alpha channel
· Set the desired source and destination alpha blending functions using NiAlphaProperty: SrcBlendMode and DestBlendMode.
Examples of common source/destination pairs are as follows:
Source Mode
|
Destination Mode
|
Effect
|
ALPHA_SRCALPHA
|
ALPHA_INVSRCALPHA
|
"Classic" alpha blending (requires alpha in texture)
|
ALPHA_ONE
|
ALPHA_ONE
|
Object color "glows" over scene (no alpha into texture required)
|
ALPHA_ZERO
|
ALPHA_SRCCOLOR
|
Object color "tints" or darkens scene (no alpha required)
|
Alpha testing is a related effect, but is somewhat independent of alpha blending.
Alpha testing assumes that the desired alpha blending mode is (or would be) (ALPHA_SRCALPHA, ALPHA_INVSRCALPHA), also known as standard alpha blending.
One problem with alpha blending is that the framebuffer and depth buffer are written, even if the alpha value of the pixel causes the blended surface to be invisible. As a result, translucent sections of objects can "block" more distant objects when the distant objects are drawn out of sorted order.
Alpha testing allows the alpha channel of a texture to be tested against a global reference value. If the test fails, the pixel is not written to the framebuffer or depth buffer. This can avoid the need to sort objects that can exist with alpha blending.
Alpha blending need not be turned on for alpha testing to work. Using alpha blending with alpha testing will tend to smooth the opaque/translucent boundaries, but can lead to "halo" effects when the objects are not drawn in back-to-front order.