Page MenuHome

Image Texture material node in Cycles handles semitransparency incorrectly
Closed, ResolvedPublic

Description

--- Operating System, Graphics card ---
Windows 7 64-bit Service Pack 1, Mobile Intel 4 Series Express Chipset

--- Blender version with error, and version that worked ---
Error:
* Blender r57620 64-bit (http://builder.blender.org/download/blender-2.67-r57620-win64.zip)
* Blender 2.67b 64-bit (official binary)
Working:
* None I know of

--- Short description of error ---
The Image Texture material node in Cycles seems to handle semitransparency incorrectly.

In particular, if the image file contains semitransparent white pixels (R=G=B=1 and 0<A<1 in straight alpha), they become either semitransparent gray (R=G=B<A in premultiplied alpha) or semitransparent whiter-than-white (R=G=B>A in premultiplied alpha), depending on whether the “Open Shading Language” checkbox in the Render tab of the Properties window is checked or not.

--- Steps for others to reproduce the error (preferably based on attached .blend file) ---
1. Save the attached files (image-material-node.blend and gradation.png) in the same directory, and open image-material-node.blend.
2. Make sure the Open Shading Language checkbox is turned off, and render.
3. Turn on the Open Shading Language checkbox, and render.

Actual behavior:
In both step 2 and step 3, the plane is rendered as gradation. In step 2, the gradation is from white on the left to black on the right. In step 3, the gradation is from black to gray to black.

Expected behavior:
In both step 2 and step 3, the plane should be rendered as black, because all pixels in gradation.png are semitransparent white.

Notes:
* The mere fact that steps 2 and 3 give different results can be also viewed as evidence that there is something wrong, but I believe both results are incorrect.
* By changing the blend type of the MixRGB node from Difference to Subtract, we can tell whether RGB are larger or alpha is larger. In step 2, RGB are larger, meaning that the output of the Image Texture node is semitransparent whiter-than-white. In step 3, alpha is larger, meaning that the output of the Image Texture node is semitransparent gray.
* gradation.png was made with GIMP 2.8.4. Just in case, I made the same image with Paint.NET 3.5.10, but the result is the same.
* The Image input node in the compositor handles semitransparency correctly.
* [#34679] and [#34966] seem related, but they are marked as fixed.

Details

Type
Bug

Event Timeline

If you use both the color and alpha output of an Image Texture node, it will output unpremultiplied/straight RGB channels. So then it is valid to for R<A or R>A. The reason it works that way is because it's more convenient for the typical mix shader node setup, if you plug alpha in the mix shader socket to blend, it already multiplies with the alpha, and you don't want that to happen twice.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures#Image_Texture

There was an issue with the OSL version not working as intended, fixed that now.

Oops, I did not know the Color output of the Image Texture node depended on whether the Alpha output was used or not. Thank you for the pointer. (I think that is very confusing, but it is a separate issue.)