Maya shader transparency and alpha multiplication

Problem statement: Black edges on object with transparency in Maya 2015, VRay 3.0.

Everyone who ever worked on integration of computer generated (CG) image over a life action video knows unpremult/premult workflow. The main ruke is before applying any color corrections to CG render it must be divided by alpha channel (unmultiplied). The whole thing about pre-multiplication and transparency is quite simple.

What in Nuke jargon sounds like “premult” in normal math language is

newRGB = RGB * Alpha

Similar for “unpremul”

newRGB = RGB / Alpha

The problem occur when you get footage which is already premultiplied and you multiply your RGB channel by Alfa again. In fact that exactly what happening when you try to use some footage with Alfa channel as transparency in Maya.

If you think your image is Unpremultiplied (but it’s really Premultiplied) and you add a Premult node you basically multiply the image twice (RGB x Alpha x Alpha). If you have an RGB pixel of 0.6 and you multiply it by the alpha pixel of 0.4 you get a correct value of 0.24 for that RGB pixel. But if you premultiply the image twice you are effectively doing 0.6 x 0.4 x 0.4 giving you a value of 0.096, which darkens the edge.

There are situations when you will want to Unpremultiply an image. The general rule for any form of colour correction is: Unpremult the image first, do the colour correction and then Premult back to its correct state. This is so you don’t accidentally colour correct any of the transparent Alpha edges. [2]

Correct workflow with premulted assets [1]
Correct workflow with premulted assets causing black edge artifact [1]


Maya Linear Workflow vs. Texture Gamma

Linear workflow is the subjects of a lot of mysteries. Indeed, it is convoluted an hard to understand especially if there are multiple ways to achieve similar but not the same result.
Linear workflow mean that all your images going trough the pipiline in linear color space. For example render output from Maya in linear space go to Nuke where get processed and render to final delivery format in sRGB.
In this article I want to show my observation end experiments that I’ve done with V-Ray and Maya and how at firs glance similar things  can produce quite different result.

The most important thing to know is that all of the renders perform calculation with linear colors, thus all the sources supplied, such as texture images, has to be linear. People often forget that shaders also need to be supplied with linear images.

Most of the source files (.jpg, png, tif, etc.) used as textures have non-linear gamma (2.2) applied to it.

Majority of render engines perform texture filtering in two places. First, when a shader process a texture, second, when the render engine calculating the image (anti-aliasing). As a matter of fact, we want to convert our images before shader start to perform its calculations, otherwise when it come to applying filtering the math will be wrong.

When you select you gamma conversion in application there are usually a couple choices sRGB and Gamma 2.2. This color spaces have slightly different curve which probably will be undistingvishble.  Here is an example of two overlapping curve taken from Nuke LUT Settings.


My test set up include two texture images. One texture used as is with gamma 2.2 color space, another was converted to linear by using Nuke Colorspace node.

brick_2_2_gamma brick_linear_gamma


First I went and disabled all of the filtering on texture as well as in render settings in order to get clean more predictable result. In term of linear workflow I’ve been testing the following cases:

Input Option
Case 1 Texture in gamma 2.2 Linear Workflow Toggle On
Case 2 Texture in gamma 2.2 Vray Texture Input Gamma 2.2
Case 3 Linear Texture All off

Here is example with  Vray Texture Input Gamma 2.2.


This image show Linear Workflow Toggle On.


With linear workflow toggle ON you will get warning saying that linear workflow toggle was deprecated but documentation doesn’t explain why, I also tried to find information on  Chaos Group forum with no luck.

Linear workflow – this option is deprecated and will be removed in future versions of V-Ray. When this option is checked V-Ray will automatically apply the inverse of the Gamma correction that you have set in the Gamma field to all VRayMtl materials in your scene. Note: this option is intended to be used only for quickly converting old scenes which are not set up with proper linear workflow in mind. This option is not a replacement for proper linear workflow.

The following image demonstrate the difference between Linear Workflow Toggle and on texture gamma correction. One main thing to note here that image corrected with VRay Extra Attribute (Case 2) has now difference with linear image without any correction (Case 3). On the other hand, image witch rendered with linear workflow toggle on has noticeable degradation in dark colors.


Most likely degradation happening due to filtering process that happening when texture get process by shader. By specifying texture input gamma on shader VRay can interpret texture to linear work space before doing the actual calculation. In case when linear workflow is turned on in render settings the texture gets filtered with non-linear gamma which lead to some errors in shader math and only after that render convert the texture to linear work space and perform further calculations.


This article was inspired by the great tutorial from Alexey Mazurenko. Unfortunately only available in Russian.

Fabulus paper from siggraph about RENDERMAN

What Ri spec newer told you