Page MenuHome

dark edge artifacts on unassociated alpha images when used as cycles textures.
Closed, ResolvedPublic

Description

Debian Testing 64 bit
GeForce 9600GT

Blender 2.66a

I'm trying to re-create shadeless materials with cycles, in order to use RGBA images as planes with no shading and transparency.
The method used is the same that the addon "Images to planes" uses (alpha is used to mix a camera-rays-only emissive shader to a transparent shader)
It works as expected with EXR files (associated alpha) but artifacts are visible when the image has unassociated alpha (PNG)

The attached file shows the problem. The left plane was created from a PNG with the described method and the right plane uses an EXR file.
It's easily reproducible using the images to plane addon to create the basic shader from a PNG and an EXR file.


Details

Type
Bug

Event Timeline

Currently cycles ignores color management settings (such as color spaces and alpha mode) when loading images. Packing images so blender side image loading is used will make alpha looking correct.

Brecht, not sure if you'll consider this is a bug or todo or maybe you already have fix for this issue.

I'm working on a fix, but there is something strange about the EXR image file here, it doesn't seem to be associated alpha? How was this file created?

Yet it somehow shows fine in the Blender image editor, but when disabling Use Alpha it's clear that the RGB channels are not premultiplied. Not sure what's going on here.

gez added a comment.Apr 5 2013, 5:19 PM

oops!
Sorry, I didn't check that. The image was created with GIMP 2.9. Apparently the exr exporter plugin doesn't associate alpha and keeps GIMP's unassociated images.
However, this might bring some interesting information, because I tried again and saved an associated EXR from Blender's compositor and when I replaced the unassociated EXR with the associated EXR in my example, the dark fringe appeared.
My gut says it's a double association: The PNG is interpreted as unasocciated correctly, so it gets multiplied. The wrong EXR is intepreted wrongly as associated, so it doesn't get multiplied. If cycles is multiplying by alpha again, it would make sense to see a dark fring both in proper associated and unassociated, but not in an unassociated image treated mistakenly as associated.

The issue is the alpha is getting premultiplied again as part of the mix shader node, actually the BSDF should get straight RGB values for color. I've changed the code now so that the image texture node outputs this when the alpha output is used. Not sure this is ideal, but I can't really automate this to give correct behavior always because it depends on the node setup and the user needs to be aware of what they are doing, so this is a heuristic to try to get the correct results in typical setups.

Brecht Van Lommel (brecht) closed this task as Resolved.Apr 5 2013, 6:44 PM

I don't really like this change, because it seems really unintuitive that the color output changes based on
whether alpha is connected. I would rather have a convention for colors being presumed premult (or it could even be unpremult),
like in the compositor. I had thought that this was already the case and any pngs that i tried here seem to come out premultiplied
already in cycles. Note that the compositor Mix node has the same problem, there it is solved with an explicit
AlphaOver node.
Also note that this might just be an issue of better documentation/presets as such an AlphaOver node can be fairly easily
recreated with svm nodes. (something like this http://www.pasteall.org/pic/show.php?id=48679 )

till then, David.