2010-01-08

Transparent Alpha Channel

 I noticed a tutorial of this for vray, and thought surely this can be done in mental ray....well it can.  Often times I create a rendering with transparent objects, and want to use an alpha channel to add a background while keeping the transparency in the foreground objects.  I'll show you how to do this with mental ray.





Now this is the image straight out of the render buffer, that I want to add an image into its background.  The reflection is from an image that I plugged into an environment switcher shader.  That way object inherit the images reflections, and the grey background that you see is just the environment background.




Max creates an alpha channel when a rendering is created.  However, only certain file formats keep the alpha channel information (.png, .tga).  I would recommend targa formats because it keeps the background, and has the alpha channel added in the same file...you can also save it as a 32 bit image which is a plus.






This is the background image that I added behind the snow globe.  This can be done in any software.  For this example I used Photoshop.





Now this is the image out of Photoshop with the snow globe and the background image using the default alpha channel.  This is the problem we get with transparent objects such as glass...notice how the background is the grey from the origianl rendering and not the lights from the background image.




The trick to getting transparency in mental ray is found in the A&D shader of the transparent objects.  Scroll down to the Advanced section and check Transparency propogates Alpha channel.  That's it!




Now when you render, and check the alpha channel you will see that it is transparent for the materials with the new setting checked.  Note: this doesn't work if materials have a map in the environment slot.







Now when you use the new alpha channel for your render, it will maintain transparency for your foreground to view the background image!








Here is the max file: 04-transAlpha_max2010.zip

19 comments:

  1. Nice work Ramy :) However I do have a question. It seems that once you applied the Alpha Channel to get the transparency in the glass, the sparkle & highlights on the glass were toned down considerably. Is there a way to preserve those? Kinda like when you apply certain blending options to layers in Photoshop. for example when you use "Difference" or "Multiply"?

    ReplyDelete
  2. Dave,
    thanks for the comment. You're right. Because the alpha channel only takes transparency and not reflections into consideration, the reflections are toned down to the same amount of transparency. You can compensate for this in 3dsmax by increasing the reflection output amount. Of course you can always play with it in photoshop as well :) !

    ReplyDelete
  3. Dave,

    I am using VRay at the moment, and the fact that the alpha channel only take transparency into account and not reflections, is... in my opinion, unforgivable! Is there no solid way to create a rich and deep alpha channel that includes the reflections and is not just a "flat grey"?

    Thanks,

    William

    ReplyDelete
  4. You can render out a reflection pass and apply it on top of the composited image

    ReplyDelete
  5. I have a small problem, i've downloaded the test scene, and i imagine it should be ready to render . . . however if i hit my render button then the render is just pure white. i have managed to get it fine by tweaking exposure to suit but i just wondered if it was meant to be like that?

    ReplyDelete
  6. Not sure why it's doing that. You're using max 2010?

    ReplyDelete
  7. sorry ramy, i am a vray user, may i know what is the link for this vray alpha channel tutorial?

    Thanks in advance.

    ReplyDelete
  8. The v-ray version of this tutorial was v-ray for sketchUp. But I'm sure it is very similar to how it is done in 3dsmax. The link is found here:
    http://software.asgvis.com/index.php?option=com_content&view=article&id=57&Itemid=439&Cctitle=Affect%20Alpha,%20Snow%20globe#

    ReplyDelete
  9. Good Work Ramy,seems like thers lot more to go for me :)

    ReplyDelete
  10. Refractions should remain with solid alphas for proper compositing. You would get more accurate results if you mapped the background image on a plane behind the globe and made it invisible to camera. Then render with a solid alpha. By making the alpha transparent your trading accuracy of the final render for simplicity. Speed vs. quality. A choice we all must make in production at some point.

    ReplyDelete
  11. hi i have a problem for my 3ds max 2010. the views are always automatically zoomed in. and after a while it gets back to normal. but when i move my cursor to the menu or to select a button, it zooms in again. is there any way in which i can correct this?

    ReplyDelete
  12. This is the tutorial I've been looking for. It's exactly what I want to happen with my glass object so I can composite it in After Effects. Unfortunately - I've copied all of the settings of the A&D material and applied it to my own glass object. But I can't get the transparency in the alpha channel. I've nothing in the environment map either. Any idea why it refuses to work?

    ReplyDelete
  13. This is a very good tutorial. Thanks for sharing.

    ReplyDelete
  14. for vray: in your material is under refract a button to say which channels should be affected.
    default is color only but if you set it to color +alpha you get the same result as this tutorial

    ReplyDelete
  15. can we get transperent avi/mov output from 3D max...?

    ReplyDelete
  16. ramy i have a doubt...plz help me.....i use mental ray for my building 3d views. as i love v ray...but there s no lightning in vray....so my question is after rendering i saved the image in jpeg but the clarity is worst can you help me rammy

    ReplyDelete