PNG/EXR Alpha Channel Problem?

Hi All,

recently i stumbled across a problem with the alphachannel of png-files in the cycles material nodes. If you look at the attached image you can see 4 spheres in the lower right corner. The 2 on the right got a diffuse material with a exr texture assigned to them (the black and white one the alpha channel output and the red one the color output of the texture).
On the left side the spheres got an diffuse material with a png texture assigned to them. The Problem is, that the Sphere that should display the Color of the png is automatically multiplied with the alpha channel. Thats isn´t a problem if you use the alpha channel as a factor in a mixshader with a transparency shader, but what if you want to use the Alphachannel as a Spec or Bumpmap and the Color in a Diffuse Shader for example?

If you look at the upper left corner of the attached image, there is the same png-texture in the compositor. Here the Color displays correct.

Hopefully somebody can explain this.


Alpha_Problem.blend (749 KB)

I can’t see any reason why png textures are behaving that way… It’s indeed a problem if you want to use png in that way…
Maybe you could search developer.blender.org to see if anyone has already posted the issue in the bug tracker.

Interesting fact, if I go to frame 0, set 3D viewport to rendered view and then select your bottom left sphere (color + png texture), select the image texture node and go to its properties panel and uncheck the Use alpha box, blender doesn’t take the alpha channel into account in 3D view…

@Little-me I think you really dicovered a bug(Sometimes it updates the Color and/or Alphachannel on Framechanges sometimes not?!). I always updated the viewport render with doubletapping Shift-Z.

I am not sure about my initial Problem - maybe it just works as intended.

I think you’re right, I’ll test if the bug still exists in the current 2.72RC1 and if no one has posted this issue yet I’ll report it tomorrow…

I’ve tested the issue in blender 2.72RC1 (2.71.6 d919218), and it seems to be working fine with that version.
You should update to that version instead of stock 2.71 to get your scene working.

There is one problem with the 3D rendered view not updating correctly whether image texture is packed or not, render works fine however.
I’ve posted the issue in the bug tracker : https://developer.blender.org/T41920

Thanks for testing, Little-me but i still got the same issue in 2.72RC1 like described in the first post. I mean it is not a real problem as could just go ahead and use different textures instead of the alphachannel but it would be nice to know if it is a bug or not.

Hmm well that’s curious because I tested your file on 2.72RC1 and it worked for me.
Are you sure that you unchecked the “Use Alpha” box in the png image texture node properties ?
If it still doesn’t work did you try testing the file I uploaded in the bug tracker ?
If you don’t get the same result as I do when doing the same manipulations then the issue goes beyond the simple png bug…

It works as it did before - if you uncheck “Use Alpha” then the Sphere that displays the Alphachannel turns completly white. Basically you can choose between a useless alphachannel or a useless color texture.

I tried your file too but its the same Problem - if you uncheck “Use Alpha” the Alphachannel is completly white and if you check it the Color gets multiplied by the Alphachannel and turns partially black. It would be nice if we were able to use both at the same time like when you use an exr instead of the png file.

Ah it seems that I didn’t fully grasp your issue in the first place then.
Setting the texture as single user in the Image Texture node should do the trick ! You can then turn the Use Alpha on and off individually.

As long as the textures are packed, your solution would work - but i think they are internally saved as different images then, which would be the same as just using two different textures. If the texture isn´t packed, this works also, but only if you don´t use the two nodes in one material.
If they are used in one material the “Use Alpha” Checkbox is overwritten in one of the nodes resulting in the described problem.

Yeah maybe packed images are duplicated internally.
For unpacked images, you can also use the single user option and it works. It doesn’t duplicate the image but my guess is that it loads it once more, resulting in 2 images in the computer RAM.
Users definitely should be able to use the alpha channel independently for each Image texture node. I don’t know if this can be classified as a bug or more as a To Do improvement… Perhaps you could post this to the developers…
I think for now the best solution is either to make a whole bunch of single user Image texture nodes or use 2 different image files, one with color and another with alpha… or use exr… Luckily these aren’t very complicated workarounds :wink:

The “single-user-option” doesn´t work for the unpacked texture IF you want to use both channels in one Material. You could try this out if you unpack one png, duplicate the Texture-Node and make it a single user. Then turn the Use-Alpha-Checkbox on one of the nodes off. If you combine the two textures(the color slot) with a Color-Mix-Node with the factor of .5 you will notice that the color is completly red or red/black depending on which texture goes into slot one of the Mix-Node, when in fact the black part should be mixed with red.

You’re right, I hadn’t tested it that way, thanks !
Well I’m out of options there, you just crossed out that solution for images that aren’t packed lol !
I’m going to add these steps to reproduce the error in the bug report I posted earlier this week…

@Little-me, thanks for posting “my bug” over on the developer forums too, but i think it is described poorly.

The Bug you have found has to do with the update of the viewport on frame changes.

My Problem has to do with how the alphachannel is treated for different filetypes, in this case exr/png, thats why it is visible on 3d-View + Render.

Thanks for your answers.
If you take a look at my bug report I did not mention the “bug” I found changing frames because I was not able to reproduce it with another sample file… However, I mentioned the problem with png alpha channels not behaving properly, as well as the different behaviour concerning packed and unpacked data.

I believe that the problem is really blender not considering alpha channels properly on png files only. I chose not to mention exr files in the bug tracker, as (1) this format works fine, the bug is only related to png files and (2) there are other formats with alpha channels (bmp, tiff, gif, svg), why choose this one in particular to compare with png ?

If you think that what I posted is not relevant to your problem I apologize. Anyways if that’s the case feel free to post another issue in the tracker, or to comment on my report with your problem if you think that it’s a related issue :wink:

No need to apologize, i am not too concerned about my “problem” as there are workarounds.

I´ve read your report again and looked at your file - you are right you didn´t referred to the update problem on frame changes in the first post. I just thought of 2 methods of updating the rendered viewport: doubletap Shift-Z which works and the Framechanges. I wasn´t thinking of it updating automatically on its own when switching the Use-Alpha-Checkbox:-)

But i still think your added comment isn´t related to your “packed/unpacked Update Problem”. The packed texture shows correctly in viewport/render because you pack single user textures (or make a packed texture single user). I tried it out and watched the filesize with the standard cube scene and a 4k texture which confirmed what i think:

BlendFile without Packed Image: .5MB
BlendFile with Packed Image(used on both texture Nodes): 3.7MB
BlendFile with Packed Image(set as single user): 7MB

That shows that the second “single-user-texture” now is in fact a totally seperate texture. Thats why it works correctly - you set use alpha or not on two different textures IF they are packed. It has nothing to do with the update of the viewport (it is just the png problem). Feel free to ask if i didn´t describe that clearly enough.

Just to get this right, I don´t want to offend you - i just don´t have an account over there thats why i was posting it here hoping you could change it so the devs don´t waste time finding out what we already know.

No offense taken, we’re all here to learn and help each other =)
I think that the developers will realize that there is a problem with the png alpha with what I said; regardless of the packed/unpacked/single user issue.
Would you like me to add another comment to the bug post anyway ? I’m not to keen on spamming the post with commentaries but if you think that’s necessary what would you want me to say precisely ?

Just a quick reply to say that my bug post has been reported to be fixed.
I did a quick test on 2.72 release and the problem seems to be gone (at least for the packed/unpacked problem).
There still seems to be the issue with alpha channel being treated differently whether in png or exr… as well as your “color mix node” issue posted earlier.
I might consider sending in another report to the bug tracker…