Page MenuHome

VIEWER: Offer premultiplied image viewing options.
Closed, ArchivedPublic


This patch solves a bug posted back in 2006 ( which has persisted to this day in Blender.

Premultiplied images are displayed incorrectly.

Sadly, there appears to be a disconnect between the CompBuf and rendering outputs that doesn't retain the alpha mode of the images passed. As a result, the images are always displayed as though they contain straight alpha.

This patch simply corrects this behavior by providing an artist driven toggle when preview with alpha is selected. Once selected, it changes the glBlendFunc to GL_ONE, which is correct for premultiplied images. It also includes an icon that corresponds with existing visual language within Blender.

The viewport rendering was discussed with Lukas Tonne.



Event Timeline

Hmmm, my own feeling is that this state should be tracked(thus making an option redundant since it -could- be determined at runtime), but I am no node expert so leaving it up to others. I understand that this change will be a lot more intrusive, on the other hand I think it's patching things up(no pun intended :) ) since operations in the compositor/renderer will inevitably need to take premultiplied flags into account(For instance the "mix" and "add" nodes). For loaded images, your patch could be modified to check their premultiplied flag as to your previous, premultiply-predivide image patch.

I originally thought that as well but I completely disagree now.

The scenario is that it is entirely likely an artist is hand crafting their own alpha and performing their own over operations using math nodes.

In this scenario, much like predivide, the artist would require the granularity to set the viewing option based on their crafted image.

The same would go for log transforms or any other custom image crafting.

It is impossible for the compositor to know these things, and would require some nasty manual flag setting in the nodes.

In all cases, it would be manual.

I don't think this is option is implemented in the right place. In my opinion images and render / compositing output buffers should have information about the buffer using premultiplied or key alpha, and based on that draw the right way. It's true that in compositing it is possible to create an image with either format, but then a scene option should be made to say that the render result image is premul or key. The reason being that not only image drawing should take this into account, but also color management transform and file saving. Specifying this once (and in most cases determining it automatic even from the file, or from the scene setting to render premul/key) would be a better solution.

The color management predivide option I can understand for backwards compatibility reasons, but this option is really working around a deeper problem.

The only issue I can see with flags is when a comp or series fails to be set and the result it out.

I will look into CompBuf but there are countless areas where manual overrides make sense. For example, what is the result of a comp using straight and premul for whatever reason? It is difficult to read the mind of the artist using the software, and more often than not, giving them control is rarely a bad thing.

Sergey Sharybin (sergey) closed this task as Archived.Mar 25 2015, 4:49 PM
Sergey Sharybin (sergey) claimed this task.

Think this one does not make much sense now.

First of all, compo is expected to output premultiplied alpha. Second of all, there's now option to ignore alpha in the viewer.

The only reason why it might be handy is to investigate intermediate buffers which could be straight alpha (i.e. buffers after keying nodes) but this shouldn't be done as a viewer node option and instead alpha type should be passed via noodles, so we always know for fact which alpha we're looking at.

Thanks for the patch anyway.

2018 and the viewer is still broken peeps. Can we fix it please?