mia_material, transparency and alpha channel tip

david | mentalray, rendering, tutorials | Tuesday, May 22nd, 2007

maya 2008 users: See update at end of this post.

The mia_material makes most of the old maya shaders some what redundant. I'm sure it will take me some time to understand its full potential and some effort to learn how it works. So on my last two projects I forced myself to use mia for everything. That way I knew I would learn more quickly. And I have to say it gave great results. It is now my preferred shader for everything but sub-surface scattering.

Here is a problem I encountered, and the solution I found. It involves transparency and the alpha channel.

Mostly I render passes that are composited in after effects, so if I have transparant surfaces, the transparency must show correctly in the alpha channel.

This wireframe shows a test setup - the orange plane with the lump has a mia_material assigned. The blue spheres are there to demonstrate the shaders transparency.

setup)1.jpg

I mapped a ramp texture to the transparency of the mia_material.shaderDiagram01.jpg

The render looks like this.

render_mia_RGB.jpg

And the alpha channel, as you can see, shows the plane as having no transparancy.

render_mia_A_noTrans.jpg

I guess that this is technically correct because the mia_material is refracting the black background, but this is not what I need for compositing purposes.

The solution is to add a "helper" plane to the setup as shown in the following diagram.

setup02.jpg

The plane behind the spheres has a black surface shader assigned to it which has it's matte opacity set to zero. The plane is flagged to be visible in refraction, but has primary visibility and most of its other render stat flags disabled.

fixTransPlaneShader.jpg

fixTransPlaneRenderStats.jpg

Now when I render the mia_material refracts the black plane instead of the background. Since the black plane has a matte opacity of zero it does not contribute to the alpha channel, and the mia_shader respects that in the refraction. Here is the result.

render_mia_A_yesTrans.jpg

update 01 May 2008: In maya 2008 this trick is no longer required so long as you remember to turn on the mia_material Advanced Refraction Attribute called "Propagate Alpha". This is possibly how it was intended to work in maya 8.5 too - but it didnt...

4 Comments »

  1. Hi,
    A lot of information has been shared...Thank You...
    This Mia_material tutorial for maya is working...
    but for 3d Max what shader should i use for helper plane..
    or is there another way... i'm facing a similar problem in max...

    Comment by photons — February 29, 2008 @ 9:47 pm

  2. I cant help you with 3d Max since I never used it. Maybe someone else reading this might be able to point to an equivalent shader.

    Comment by david — March 1, 2008 @ 12:18 pm

  3. Hi,
    thanks a lot for sharing your knowledge, really very informative and instructive,
    But i have to mention that Propagate Alpha must be cheeked in Advanced Refraction of mia_material, otherwise we can't get transparency .
    by the way i love your technique

    Comment by rachid — April 15, 2008 @ 6:31 am

  4. Thanks rachid, for that tip and your kind words.

    Comment by david — April 15, 2008 @ 11:22 pm

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck