My mental model of how alpha opacity works is wrong (2020)
coolbutuseless.github.io
coolbutuseless.github.io
If you have two translucent objects, how do you combine the colors? This is hard to do with Z-buffer rendering. The obvious coloring operation is not commutative, and in a Z-buffer system, you don't know which face gets rendered first.
This is a huge pain. You can't just dump everything into the GPU and let it draw in parallel, which is what GPUs do fast. You usually have to depth-sort triangles, so the front triangle gets rendered last. This delays rendering while the CPU does the sort.
There's a GPU-based solution to this, but it involves some compromises in quality.[1]
[1] https://developer.nvidia.com/content/transparency-or-translu...
To be honest, the game developer way of solving this is to just not use transparency. Too many things rely on the G-buffer / depth buffer these days, and transparency is usually limited to a lower quality render anyway.
This is just the tip of the iceberg when it comes to the complexity of translucent objects. To get truly convincing results spectral rendering is needed, but of course that is prohibitively expensive for real-time use.
Looking through a yellow filter at a yellow flourescent light - you could easily see almost all the original light (bright yellow) or none (black) depending on the spectral transmission of the filter.
https://www.youtube.com/watch?v=zcqZHYo7ONs
…I think it actually isn't and the people explaining it have just forgotten it's supposed to be a metaphor though.
Also, polarization as a degree of freedom arises out of symmetry considerations, and that's what you learn in QFT.
There’s another GPU-based solution with RTX and other ray tracing solutions that is high quality. Might be compromising efficiency in some typical cases, unless a lot of geometry and/or instancing and/or samples are used, and then in that case it may be both an efficiency and quality win.
If we're just talking transmission they would both be the same, ie transmitting all red photons and 50% of the green and blue ones while the other filter transmits all blue photons and 50% of the red/green ones. Either stack has 50% red values, 50% blue values and 25% green right?
However, if we're talking about how alpha blending actually works in software, then it can vary a lot.
For example, in Direct3D you would typically use the `D3DBLEND_SRCALPHA` and `D3DBLEND_INVSRCALPHA` for the source and destination blend modes respectively. In that case, the combined alpha is actually `src_alpha^2 + (1 - src_alpha) * dst_alpha` which is different again from the two calculations in the article.
There are even other ways to achieve a physically realistic result that use a different interpretation of the alpha channel. Or maybe you want to solve for something else (eg. order-independent blending)
then i remind myself that i probably have a few situations like that in my own mind and i should remain vigilant.
edit: and then i get just a little more frustrated next time someone resists a correction that i provide.
The thing that you might be missing is that "incorrect" is (usually) objective, but "unintuitive" isn't necessarily so. I can see how someone else would think additive opacity is intuitive, even if it's very easy to show that it isn't correct.
You are right that "intuitive" is a subjective property. But I'm completely lost trying to imagine what kind of life experiences can lead on to expect them to be additive.
Seem intuitive to me. Half + half = whole. When I make a chart in R and set the color to alpha 0.5, the result looks more or less like an opaque point if I plot 2 of them on top of each other.
Apparently that's wrong, but it's consistent with my not-very-precise observations, and I have never had a need or desire to learn more about how opacity works. One cannot be an expert in all things.
What intuition should a layperson have to suggest that obviously opacity/transmissivity is multiplicative? I don't see the value in deriding the incorrect intuition of uneducated people. In statistics at least we accept that statistics is hard specifically because it can be unintuitive.
Should have been obvious, but I never thought about it.
It's a very common operation in graphics. Even so that certain graphics processors have a flag for floating point operations which allow the results to be saturated (clamped to [0,1]) at no extra cost.
I know I prefer to avoid it and design equations so it isn't necessary. That often helps make the math cleaner and more well behaved. But repulsion sounds stronger than what I feel.
I would say there are plenty of cases where things do act additively yet we wish to clamp their values to a specific range (often valid colours).
On a physical model, it is a very strong signal that you messed something up and your model is wrong. Sometimes you get something that looks like a sigmoid but has the exponential parts very short, so it looks like a clamped linear function, but you normally need some kind of mechanism limiting the output on the linear region. Simple phenomena do not have clamping, it is a very complex operation.
My intuition is that if I put on dark sunglasses I can still see through other dark things (like a CD or welders glass) if I look at something bright enough (like the sun). If opacity/transmissivity is modeled like it works in real life, given this example, it follows that it wouldn't be additive.
Tinted windows and sunglasses come to mind. Intuitively, if you put translucent things back to back, you expect light to still pass through, albeit less of it, but always some. A noteworthy exception is when using polarized filters, which can unintuitively block out 100% of light depending on the angle between the filters.
E.g. when you mix two grays (#80808000) in RGBA space you probably don’t expect white. None of R, G, B, A are additive in a sense of color/transparency mixing. They are only additive component-wise regarding the resulting color, i.e. R+G+B is a color, but two reds aren’t 2R.
I, on the other hand, am completely lost trying to imagine what kind of life experiences can lead one to believe the OP error requires some "unique/rare" life experience.
How about the very common life experience of
(a) not being good at math but still being a programmmer and having eventually to deal with something math-y?
or
(b) the life experience of someone who might now enough math to get this, but didn't give it alpha opacity much thought before, and the simple addition model was good enough for them (as they never had to do anything special with it)?
That said, I’m well aware that opacity is multiplicative, and yet it still caught me off guard before to realize that the commonly used lerp blending mode (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) is incorrect in the alpha channel. Pre-multiplied alpha can also be unintuitive at first, even with a decent mental model.
Or are you just pretending not to know to seem more relatable?
So to give some examples, a material with 100% transmission would have a density of 0, a material with 10% transmission would have a density of 1.0, and a material with 1% transmission would have a density of 2.0.
Density values have some advantages, including:
- They can be combined with simple addition
- Compared to transmission or opacity values, they correspond more closely to human visual perception
Been too long since I've done computer graphics, but you made me think about implementing transparency pass using absorbance instead.
[1]: https://en.wikipedia.org/wiki/Absorbance#Absorbance_of_a_mat...
[2]: https://en.wikipedia.org/wiki/Transmittance#Beer%E2%80%93Lam...
https://en.wikipedia.org/wiki/Alpha_compositing
If your compositing operation is A over B, then transmissivity is multiplicative for the A&B region. If your compositing mode is A in B, then opacity (alpha) is multiplicative.
This has the same structure, mathematically, as thinking about logical operations like AND and OR, which are complementary to each other. If you think of AND as multiplication, well, you can think of OR as multiplication as well, just with the values flipped around.
It's all just an approximation. Don't lose sight of that!
[1] https://graphics.pixar.com/library/Compositing/paper.pdf
The best docs I could find in a short amount of time, are those from anti-grain[1] where the author describes it as a "second alpha channel.
[1] http://agg.sourceforge.net/antigrain.com/doc/basic_renderers...
I have a mental model of how an elevator works from using them many times, but it's absolutely a simplified understanding of the real mechanisms at work. I believe elevators are fully understandable but I don't need that level of detail to operate one. If it became important to know more about them (say I was in an elevator that malfunctioned) then I'd invest more in making my mental model more correct.
So to me, mental models aren't necessarily intentionally or consciously formed and they can certainly be used for quick simplified reasoning about things that may be in fact well-understood.
Its more mentally simple than 'opacity' ('transparent' is a more common word than 'opaque' to hear used in the real world - as 'opaque' is the default of most objects/surfaces, having 'transparency' is a special property that needs to be described), more correct than 'translucency' (also used commonly including in this thread but in real definition means an object that passes light but not a clear image of what is behind, like a frosted window - light is not travelling in a straight line but is being bent) or 'transmissivity' which the author uses (needlessly making it more technical and opaque to the end user - and actually less specific as transmissivity could be translucency also)
Rebelle: Experimental online paint software https://news.ycombinator.com/item?id=30191520 (3 days ago, 22 comments)
https://en.wikipedia.org/wiki/Alpha_compositing#Straight_ver...