Friday, March 05, 2010

Creating custom render passes in Maya & Mental Ray

Been studying up on how to create some render passes in Maya/Mental Ray. I'm using 2008 (so sue me), but this should mostly be applicable to 2009/10, as well, because there are some issues with the render passes coming out of both of those versions (mostly much longer renders, as Sagroth talks about HERE).
Basically the idea is to use the mia_x shader in particular to get a full spectrum of render passes basically at no cost (or little cost) to the render time of the images. This can be HUGE when you're rendering a longer animation or a series of animations.
Problem is that it's REALLY complicated, so I do it in three parts here. Part 1 talks about why you'd want to do this, Part 2 talks about the basic setup in Maya using the SimplePasses shader (which you can download HERE) and Part 3 talks about adding multiple shaders to your passes (both multiple mia_x and other custom passes) and some things to look out for re: render layers.
BTW, the script I'm using in the vids is here, though I make no promises about it. I fixed a couple things and can't replicate the weirdness from the 3rd vid, so I think . . . think . . . it should work OK for most things. To use it, source it, then type "zbw_renderPasses". If you open it in a text editor, there are some basic instructions in the header . . .
So anyways, here are the vids :)

Maya/Mental Ray: Custom Render Passes (Maya 2008) Part 1 from zeth willie on Vimeo.

Maya/Mental Ray: Custom Render Passes (Maya 2008) Part 2 from zeth willie on Vimeo.

Maya/Mental Ray: Custom Render Passes (Maya 2008) Part 3 from zeth willie on Vimeo.


  1. Hi, first of all I would like to thank you for putting up the script and the vids.
    Really useful and it sheds a new light.

    I tried using your script and followed exactly as you instructed in the video.

    The funny thing though is at the RenderLayers tab of your script I chose the renderlayer and for some reason maya tells me :

    Error:Object not found: Out00_resultCB

    Plus I can't find the list of Output Passes. I've no idea what I've done wrong. I checked through all the procedures that would have been done manually if the script wasn't used.

    Either I missed something out or I did something wrong along the way.
    Strangely I did try "set up passes" again and for that one time among many times, it actually worked. Currently now it doesn't work anymore.

    So now I'm wondering what's happening. Could you help and advise?

  2. Neo-
    Sorry for the delay. Been really busy with work, etc.
    Yeah, it does seem like it can really be wonky with the script. Really touchy. First thing, my bad, but it'll work better (I find) if you rename it without the "_v01". . .
    The other issue is that to use mel to get the custom framebuffers and outputPasses into the lists in Maya that they need to be in to be seen, there's a fair amount of "forcing" them into slots that don't really exist (like when you try to get numbers into the +/- avg nodes). So while I know exactly where they want to go and Maya will put them there automatically when you manually create the FB's and OP's, there really no way that I can find to easily tell Maya which slot on the framebuffer list (which is what you need to see the FB in the windows) things should go in. So I'm just kinda forcing it in and then renaming it, so you never need the list value again. But sometimes I get "The destination attribute 'miDefaultOptions.frameBufferList[0]' cannot be found" which is crazy, cuz it should still be there and be empty. I'm pretty sick of trying to figure it all out, so I don't know how much more work/research I'd be willing to put in. If I figure anything out to make it work more smoothly, I'll definitely let you know. . . Thanks for the comment.


  3. Thanks for replying and no worries about the delay. I understand. =)

    And also thanks for the advise and heads-up. Good luck! =D

  4. Hi Willie,

    First want to say what a great blog you have and thank you for openly sharing your knowledge with the public and taking the time to record these great videos.

    I am having a slight issue with the render passes in that when I set the file type to exr, the additional output passes are black! The primary buffer renders fine but the additional passes are black.

    However if just change the output type to tiff, then they render correctly.

    Each pass is being rendered as a seperate image, not a combined exr file.

    Have you had this issue before?

    I am using maya 2008 ext2 p01 64bit, with simple passes windows 64bit.

    Maybe this is a bug with simple passes on this platform.

    I will try it on Mac and see what happens.



  5. @Richard-
    Thanks for the kind words. . .
    yeah, I've found exrs in 2008 to be a bit wonky. But having said that, they work for me, rendering out to separate files for each pass. . .
    Since it's working with tifs, I'm guessing you have all the settings at the camera output window working right. Just for haha's I might just set the bit depth to 32 rgba (I KNOW those work fine). Also make sure you've got your frame buffers connected in "use user buffers", etc.
    I would guess that the problem (assuming it's not just some bug) is in the "file name postfix". You need to make sure each pass has a separate name. If they have the same name they will automatically render to a combined exr (don't know why you'd get separate files in that case, though).
    I think you may also need the "OpenEXRLoader" plugin loaded to render exrs (not sure), but I don't know what kind of error you'd get if that were the problem. . .
    I don't think it could be a bug with the simple passes if tifs are rendering correctly, because sp doesn't really do that much but pass the info. The problem is more likely in the camera outputs, etc.
    Sorry, hope that helps. Let me know if you figure it out.


  6. Thanks for the fast response.

    It is strange because my primary framebuffer is set to 32bit exr and that renders out fine with the image, but it is just the additional framebuffer pass exrs that are black.

    I tried setting up the passes manually rather than using your script, and got the same problem.

    So I am a little unsure what the issue is.

    Each pass has a separate name in the "file name prefix" so each additional pass is rendered to a seperate exr.

    In nuke, you know when you have a rgba image you get the little colour bars on the left corner in the image thumbnail, well for the black exr renders i do not get any colour bars but rather a little dark green bar in the bottom right corner of the thumbnail. Any idea what that means?



  7. Question for you!

    So, your passes tutorial is awesome. Works great for me.

    My question is when I turn on Final Gather, the final gather effect is evident in the main beauty pass (framebuffer 00), but doesn't seem to exist in any of the other passes.

    Is there a way to make the lighting affect of the final gather appear in the other passes? Am I overlooking something simple? Any help would be much appreciated.

  8. @BMDela- That's strange. I suppose it would depend to some degree on WHAT the other passes are (i.e. are they things that final gather would affect). What are the other passes you're sending out?

    @Rich - no idea what the little green chips are, but I don't have Nuke in front of me at the moment. Did you ever find out?


  9. Thank you very much Zeth, your tutorial is really awesome! Amazing stuff... In maya 2011 there are still some problems with render time, in my case the render goes two time longer with standard way of creating ouput passes...
    Your way is a little bit complicated but i like it :)... Thanks again!

  10. Hi Zeth,

    first of all I would like to thank you a lot for your very good tutorial. That is something I was trying to learn for more than 3 weeks. It has really well explained the process.

    I wanted to download "simplePasses" from mentalRay server following your link but the server seems to be down.. Do you think you could help me on that some how please? I have Linux64. Maya2008.. I would really appreciate as I could not find any other thread on this shader.

    Thank you very much in advance.


  11. Jakub-

    Doesn't really even NEED simple passes, that's just the one I used. Sagroth actually goes over some other options here:
    You could probably also use deex shaders as well. The concept is the same, all you really need a buffer to catch the outputs of the mia-x shader to pass to framebuffers. Since I have no affiliation with simple passes and what builds are avail, ect I can't really help you there. But I'm positive there will be something out there that will do the job . . .
    Good luck!


  12. hi Zeth,

    i've learned a lot !, thank you, its very well explained and understandable for me, all this time i thought the render layers and render pass are the same XD
    even thought setting up a render pass its very complicated, but i guess its really worth it in the end.

    one question, right now im having difficulties with trying to compositing the rendered passes within nuke. and im curious, will in the future we'll see some tutorial about composite with nuke from you ?.

    hope my english doesn't give some misunderstanding.

  13. hi zeth i love the way you explain the suff before hand in sketchpad before you do the step by step explanation.It really helps us understand the need for following your action and not just follow blindy :) your tutorial portal light is also a great help.I think you explained it even clearer then how my teacher taught us ! Keep up the great work ! will follow your blog for more knowledge

  14. Awesome tutorial. This explains so much more, and its in basic enough terms I actually understand. Thanx for that. Not that it's necessary but is there anyway you can send a link for the script you made?

  15. First of all, I wanna say thank you for your great tutorials, that make my head clear about passes/buffer relationship. Im trying to re-make my huge scenes for rendering with this method. and I understand its kinda complicated as you talked in vids. Is your script nolonger available?

  16. Wow. Two requests for this busted old in one day :)
    Don't know how the link got messed up, I've fixed it in the original post, but the link is:
    for those who don't care to go back up there. I migrated to 2010 shortly after this post, so I haven't revisited this at all really and make no guarantees about it's effectiveness (there are some real headaches with scripting stuff for things like framebuffers and outputs and stuff like that that is "hidden" from the end user). It should work most of the time if you're using the Simple Pass shader.
    Anyways, hope this helps a bit . . .