3 ms·
The author of the article here. I know what you mean about my example. I in fact started with an example of red (255,0,0,255) texel next to fully transparent (0
by erich666 11y ago
The author of the article here. I know what you mean about my example. I in fact started with an example of red (255,0,0,255) texel next to fully transparent (0,0,0,0) texel, but found that example unconvincing - you don't really see the effect of premultiplication directly, as both texel values look exactly the same whether you premultiply or not. Really, another way to write the article would be to say, "whether or not you want it, the GPU will return premultiplied-looking values when you bilinear interpolate or mipmap." The interpolated value for (255,0,0,255) and (0,0,0,0) is (127.5,0,0,127.5). The only logical way to interpret this value is as a premultiplied value. I hope this helps. I'll add a sentence or two to the article along these lines, as it might help others to get what I'm trying to describe. Thanks for pointing out the confusion.
- dahart 11y agoEric, I've had this point in my head, but I missed that you were making it, and furthermore I missed the true meaning of your post's title! It is true, and interesting, that whether you use unassociated colors and blending functions or you use premultiplied colors & blending functions, either way, what comes out is a premultiplied color! This is true of any software compositor or renderer too, right? It's a fact of rendering, not just of GPUs, that output colors are premultiplied. The over operator multiplies colors by the source alpha values while you blend - that is where "premultiplication" happens when you render or composite something. Some software renderers have an "un-premultiply" flag to do a divide right at the end, so you can spit out files with unassociated colors in them, but otherwise anything rendered comes out premultiplied. I believe this is exactly why WebGL defaults your canvas to premultiplied compositing over the rest of the page. Your output is premultiplied even when your input isn't. It is also a good reason to think in pre-multiplied colors and use the blending functions that assume pre-multiplied colors, and pay attention to, and convert/premultiply on the fly, when you need to accept unassociated color sources like hand-painted textures.