FIXED: Alpha premultiplication issues

Hi @malcolm

I have an issue with proper and consistent handling of textures with alpha.

Please also see the examples in the toe file as it’s heavily commented
premult_issues.toe (7.5 KB)

Example 1
Basically I can only get a correct renderings (i.e. no dark outlines) if my textures are not pre-multiplied and the shader has “post mult” enabled . But most of the time it’s a huge pain if not impossible to have all textures unpremultiplied (they need to be shown in UI, composited, …)

Example 2
If the textures are pre-multiplied and the shader has “post mult” enabled, I always get dark outlines, improper fading, …

Example 3
If the textures are pre-multiplied and the shader has “post mult” NOT enabled, these gliches disappear,
but then the alpha parameter of the shader doesn’t work as expected

Example 4
The only way I can get a proper rendering without dark borders and a working alpha parameter is a custom shader (see to file)

Am I missing something here?

Thanks Achim. Yep, this is definitely a deficiency. I think the correct algorithm is to make sure all the input colors are already pre-multiplied, and then you can just combine them together safely, and don’t apply a post-mult alpha at the end. So for your custom shader you would create a material color using

(uConstant.rgb * alpha, alpha)

And then that can be multiplied by the texture which is already pre-multiplied. That creates the correct output as well, and I think that’s the real ‘correct’ solution.

So for our MATs in general we already assume textures are pre-multiplied. What we don’t handle correctly is pre-multiplying other color inputs such as the point/instance color, or the material color properties. I’m going to look into doing this for 2021.30000, but may backport it for 2021.10000 depending on how the solution looks.

Ok I did a large rework of this in the 2021.30000 series. We try to generate everything pre-multiplied on nodes that generate color, and materials that consume color and textures assume things are pre-multipled. The old ‘Post Multiply By Alpha’ behavior in MATs is considered legacy and there is a toggle to enable it. Old files will load up in Legacy mode to avoid changing old file behavior


sounds great. looking forward to having no more black outlines in my renders