利用者:Sobotka/Alpha/So WTF is Alpha
目次
WORK IN PROGRESS
So WTF is alpha?
Alpha is simple right? It's a measure of opacity. Move on. Nothing to see here. Right?
This page is an effort to demystify the alpha channel and hopefully shed some light on cares an artist should take when dealing with it.
There is an adage that applies to computer color that equally applies to alpha. "If you think you understand alpha channels, then you probably do not understand alpha channels."
Q: Is alpha a measurement of opacity?
While this may seem like the simplest question, it does in fact have a buried bit of complexity. The short answer is "No." The reason for this somewhat radical answer will hopefully be more clear by the time you finish reading this document.
Q: All of these terms! Arrrgh! Why do people make this so complex?
Part of the issue with alpha is that the traditional terminology has unfortunately confused the issue. When one says "multiply" in a statement, it immediately implies a certain reversibility and a focus on the mathematical side of things.
Unfortunately, the math aspect fails to adequately express the issues around alpha, and as such, the terms muddy the waters further.
Q: What is alpha?
The alpha channel was invented in 1977 by Alvy Ray Smith and Ed Catmull.
Alvy Ray Smith on Alpha
There are two ways to think of the alpha of a pixel. As is usual in computer graphics, one interpretation comes from the geometry half of the world and the other from the imaging half. Geometers think of “pixels” as geometrical areas intersected by geometrical objects. For them, alpha is the percentage coverage of a pixel by a geometrical object. Imagers think of pixels as point samples of a continuum. For them, alpha is the opacity at each sample.
In the end, it is the imaging model that dominates, because a geometric picture must be reduced to point samples to display -- it must be rendered. Thus, during rendering coverage is always converted to opacity, and all geometry is lost. Imaging Compositing Fundamentals https://www.cs.princeton.edu/courses/archive/fall00/cs426/papers/smith95a.pdf |
Q: What are some common terms around alpha? What do they mean?
Charles Poynton once issued a plea for accurate terminology. This plea is echoed here.
It is the firm belief of the author that using mathematical terms to discuss alpha buries the issues for many artists. To this end, the following list of terms are outlined for clarity.
Associated Alpha
The form of alpha where the RGB values and alpha values are mathematically combined and considered differently during the combination step. Alvy Ray Smith and Ed Catmull originally labeled this form of alpha as premultiplied alpha.
However, while a portion of this approach originally was considered for efficiency purposes, it also represents a critical conceptual departure to be discussed later.
Unassociated Alpha
The form of alpha where the RGB values and the alpha values are [i]not[/i] mathematically combined, but rather considered as separate entities. Also called key or straight alpha.
Occlusion
The amount an object prevents light from transmitting through its respective region. Similar terms include opacity and transparency.
Emission
The amount of light that is transmitted through a given region.
Q: How do we composite an image over top of another image?
In order to discuss this, some extremely simple math is required. The first thing to notice however, is that there are [i]two[/i] methods to achieve this. The reason is that the alpha types listed above are in fact [i]different[/i] and have different implications.
For clarity and to highlight the key differences between the two approaches, will keep the procedures as simple as possible; the background is considered fully opaque.
Alpha and Light
It can be helpful to view a discussion of alpha as synonymous to a discussion of light. Light is an additive creature and it intrinsically geometric. Ratios play an important role in how to properly deal with light, as opposed to simple addition and subtraction. Think of it as scaling light.
|
Q: How do we composite an unassociated alpha image?
(Foreground.RGB * Foreground.Alpha) + ((1 - Foreground.Alpha) * Background.RGB)
If we were to try and verbalize what is happening in the unassociated alpha operation above, it might read as a series of logical steps:
- First we must scale the Foreground layer's RGB value by its respective percentage alpha.
- Then we prepare the Background by knocking down the RGB values where the image will land. To do this, we take the remainder or inverse of the Foreground image's alpha and scale the Background's RGB values by the amount.
- Finally, we add the scaled Foreground image's RGB values to the knocked out hole we have created in the Background.
Q: How do we composite an associated alpha image?
Foreground.RGB + ((1 - Foreground.Alpha) * Background.RGB)
If we were to try and verbalize what is happening in the associated alpha operation above, it might read as a series of logical steps:
- We prepare the Background by knocking down the RGB values where the image will land if there is alpha / occlusion. To do this, we take the remainder or inverse of the Foreground image's alpha and scale the Background's RGB values by the amount.
- We then finish the operation by adding the Foreground's RGB values to the entire image.
Q: OK. So what?
It should be noted that a key part in this discussion is that an alpha format indicates what alpha operation to use, not some mathematical detail about the data.
This leads to several cases where the two formats are radically different, and where one format and only one format is capable of representing certain physical, real world representations.
Q: What are the differences?
First instance is a real-world glow, emission, or halation. In associated alpha, we can express an emissive and non-occluding or partially occluding value simply by:
RGBA = {12.8, 11.2, 0.3, 0}
In the above, the value would amount to a basic add once the correct compositing operation was chosen.
Add Image Here Please
Add Image Here Please
|
The unassociated alpha image however, can not represent semi and non-occluding pixels that emit light. It is fundamentally impossible.
Q: Are there other differences?
In an associated alpha images, the four channels can be treated equally, whereas in an unassociated alpha image they cannot.
Consider a slightly blurred blue cube overlapped by a slightly blurred red cube against a fully unoccluded background.
Add Image Here Please
Add Image Here Please
|
In an associated alpha image, the four channels can be blurred as a whole, resulting in a perfectly acceptable image.
Add Image Here Please
Add Image Here Please
|
In an unassociated alpha image, this is impossible and the image must be manually dealt with.
Add Image Here Please
Add Image Here Please
|