r8 - 16 Feb 2013 - 01:48:31 - MattEstelaYou are here: TWiki >  Maya Web > MayaToHoudini > MayaPlugins > MayaRender


Render passes

Maya as of v7 has pretty good render pass support now. The maya software render still doesn't do renderman style arbitrary output variables and probably never will, but mentalray does through framebuffers (which are almost officially supported in v2008). More on that later.

If you've not created render passes before, you might be wondering what the big deal is. A lot of the final steps of rendering are tiny changes. A touch more specular, toning the colour down a bit, a hint more reflection etc. If you're doing these tweaks within maya, each change will require re-rendering the entire frame, despite the fact that you're only changing one property by a small amount.

If you know a little about photoshop, you'll soon realise that a maya shader is kinda like a photoshop layered psd. The diffuse channel is your background, the specular is a new layer with a 'screen' blending mode, ambient occlusion and shadows are 'multiply' blended layers, reflections are 'screen'... in fact, pretty much all the components of a shader are either 'screen' or 'multiply'.

Taking this a step further, rather than let maya composite these layers for you in the render view, you can generate seperate renders for diffuse, spec, ambocc, reflection, and put them together in photoshop. Altering layer blending modes and opacities is instant, and lets you quickly zero in on the look your after.

Furthermore, you can create extra passes that you use as contol layers, or the basis for masking effects. This way you can do fancier stuff like light wrapping around the edge of an object, depth-of-field, or even completely re-texture and re-light objects after they've been rendered.

A great book for learning these techniques is Digital Lighting and Rendering by Jeremy Birn, go buy it!

Andrew Chapmans render pass plugin (for pre Maya 7 users)

If you're trapped pre maya 7, creating render passes is a very labour intensive process. To create the passes involves following a sequence of steps like:

  • Pass 1: hide object A, turn key light on, enable raytracing, disable shadows, rename your output render, render
  • Pass 2: Save with new name, show object A, assign this shader, disable raytracing, render
  • Pass 3: ...

Invariably, this sort of mind-numbing drudgery is done by hand, late at night, the day before the shot is due, which is prone to mistakes and nastiness.

Help is at hand for you pre 7.0 people through Andrew Chapman's render pass plugin.

This RenderPassTutorial? takes you through using Andrew's plugin to automate splitting a render into beauty, diffuse, spec, shadow and ambocc. Ideally you'd use the ctrl_buffer shader, but lets pretend I wrote this tut before hearing about that shader, and pretend I even wrote it this way on purpose so as to be easy to understand. Its definitely not because I'm too lazy to re-write the tutorial. No sir.

Go read the RenderPassTutorial? .

Render layers in maya 7

The new render layers system is based around the concept of overrides. You tell each layer what objects should render in that layer, and what properties of those objects will be modified, and maya will keep track of those changes as you switch between layers. Quick example, we'll create a simple specular pass:

  • Create a sphere and a light, assign a red blinn shader to the sphere
  • Select the sphere and light, and click the 'create layer with selected objects' button.

Now maya knows these 2 objects belong to this layer. We'll now tell maya what properties we'll alter. To create a spec pass, we'll change the diffuse colour to black.

  • Select the new layer
  • Bring up the blinn shader in the attribute editor
  • Right click on 'color', and choose 'create layer override'. The color label will turn orange to show you maya is watching this attribute now.
  • Set the colour to black.

Thats it! If you go back to your render layers, you can switch between the 2 layers, and see the sphere change from red to black.

More on render layers

If you have lots of objects and lots of shader changes, marking individual properties to override would get tedious pretty quickly. Alias must've anticipated this, and have several ways to speed this up.

First, material overrides. A pass you make might need every object to have the same specular highlight. In that case, make a new material that has the spec you need, name it 'mySpecMaterial', then on that layer right click and choose 'assign existing material override -> mySpecMaterial'. Maya will then assign that material to every object in that layer. But if you go back to another layer, the original materials will be restored.

Another is presets. 90% of the time you'll be making diffuse, spec, shadow, occlusion etc passes, so there's shortcuts for setting this up. Again, create a layer with the objects you want, then right click on the layer, and choose 'presets -> occlusion', or whatever you want. You can also define your own presets.

Finally, you'll find that maya often doesn't need to be explicitly told which properties to watch; its smart enough to know 90% of the things you'll change, and watches them anyway. This includes things like

  • Per object visibilty
  • Per object render stats (primary visibility, visible in reflections, cast shadows etc)
  • Per object shader assignment
  • Most render globals (even as far as which render you choose, so you could do spec in maya hardware, and occlusion in mentalray!)

Personally, I find it better to set overrides by hand just so I know what's going on, but that my slightly anal tendencies.

Mel Render Layer Overrides GUI


I had a section explaining how to add mel to render layers by hand (now moved to MelRenderLayersByHand ), but it was crying out for a neat little script, here 'tis. The original goal was to use Chapman's GUI and re-write the underlying code, but it was too complex, and besides, a lot of the maintenance stuff is now handled by the internal layer features anyway. To use it, create a shelf button that contains

showMelOverrideEditor(`editRenderLayerGlobals -q -currentRenderLayer`)

This will open the window shown above, and load an override for the current layer if it exists. The script sets up the layer change script triggers, and drops in the appropriate pre and post render commands. Its quite minimal, and doesn't do any error checking, so test it properly before using it in production. If you find any bugs let me know.

A minor annoyance is if you use disconnectAttr. If the nodes aren't connected to start with, maya generates an error. Normally not a problem, but if your renderfarm software is paranoid about errors (like Deadline is), it'll halt the render. To fix this, wrap the statement in a 'catch' command, which hides the error:

catch(`disconnectAttr file4.outColor FurDescription1.BaseColor`);

My next big task with this system is to have it convert maya's render layer overrides into mel statements. Too many times now have render layers fucked up, and there's no way to salvage it. Having all the changes in text form should at least make things fixable, and ideally have a little library of pre-made render layers. Wouldn't that be nice?

Per face render layers

The documentation states you can't do per-face layers. Thats not entirely correct, although it does seem fragile, and best avoided if possible. Here's an example scene with it working: perFaceRenderLayers.ma


The easiest way to see whats happening here is to drag the 2 blinns into the work area, then from the shading groups tab drag the 'upperSG' and 'lowerSG' nodes to the work area as well. As you change layers you'll see the attribute override I've created. Don't just do a 'graph upstream /downstream', it brings in too many nodes by default and is a little confusing.

Basically I'm using the shading groups as selection sets, and using layer overrides on the material->sg attribute. the slightly confusing part is you have to assign the seperate materials first, so that the shading group 'sets' are correct, then go back and change them after you setup the layers. probably easier to understand as a sequence of steps:

  • create sphere
  • create 2 materials, map a checker to one, a ramp to the other
  • show upstream connections on both, and to make things completely clear name the shading groups 'upperSG' and 'lowerSG', and the materials 'checkerBln' and 'rampBln'
  • get into face mode, assign the checker to the top half, and the ramp to the lower half of the sphere

  • select the sphere, create new render layer with selected objects
  • select upperSG, open the attribute editor, right-click on the 'surface material' title and choose 'create layer override'
  • go back to your master layer, and drag the checker material to the upperSG material slot

That should be it. Maya seems to get a confused if you make changes in ways that maya can't track, like deleting layers while in the layer, or making new per-face material settings that conflict with the current layers, so handle all this with caution... smile

Mentalray framebuffers via ctrl_buffers

You might notice when you create your render passes that your full beauty render doesn't take that much longer than rendering just a specular pass. Its the act of rendering that's slow, but internally the renderer can calculate the diffuse, specular, reflection and shadow elements of each pixel pretty quickly.

Knowing that the renderer is calculating these components seperately, and comping them at the last minute, it seems there should be a way to say 'do that, but don't comp them together at the end, just save them into seperate files'. This is what renderman arbitrary outputs, and mentalray framebuffers allow you to do.

Unfortunately, both renderman and mentalray expect you to do some shader coding to access these features. The amazingly clever ctrl_buffers shader by francescaluce has put an end to that. Have a read through to see how it works. The ideal world of drag-n-drop, GUI based framebuffer creation is here. Woo!

Render managers

From the personal endorsement level, I highly reccommend Deadline. If you're windows based, and want an absolutely rock solid render manager thats easy to script, with excellent support, go Deadline. Spider shows lots of promise for free software, but its more abandonware now, doesn't play with XP well (it was designed around NT/2000), and caused more headaches than it helped.

If you're resourceful you can always write your own. I did this a while back using python, xml-rpc and postgresql, using zope to make a nice web front end. The splitting and metadata stuff is pretty easy, the hard part is process control in a cross-platform environment.

The latest python has a new process control module that looks great, but it'll be another version or two before it has everything needed to do render management easily. Might dig out the old code when it arrives. If anyone is interested in the code as it stands, drop me an email and I'll send what I got.

After seeing how render management works at large studios like framestore and the mill, I'd probably re-write from scratch anyway. Something that I didn't touch before was job dependencies, eg, a job might entail several passes, then a shake script to put it all together, then a mpeg output at the end. The render manager should be able to do all this for you, and recognise that it can't start the shake job or mpeg output before the passes have finished. One day. One day...

-- MattEstela - 29 Sep 2006

Optimising Renders

Getting more render options

showEditor defaultRenderGlobals;
Or more accurately, older render options. Everything in these tabs should have matching values in the regular render globals, but choice is always good. Note that it's probably not compatible with maya 6.

Hardware Renderer

Hardware rendering at greater than screen res

You need to go to hardware render buffer attribute editor and check 'full image resolution'. You can create your own presets to make massive renders.

Hardware render buffer forgets image dimensions

Under linux anyway; if you reload a scene and use the hardware render buffer, be sure to set the image dimensions again, as it seems to reset to 640x480, regardless of what the hardware attribute editor says.

The maya hardware renderer (maya version 5 and up)

You wouldn't want to swap between renders mid-shot, but if you're short on time, it can get pretty usable results. Even using it for matte passes can be a big timesaver.
  • softwareHalf.jpg: render time 13 seconds at 1024x576
  • hardwareHalf.jpg: Render time 1 second at 1024x576

Command Line Render

  • There's a lot more options, all in here: MayaBatchRenderOptions
  • Look up 'batch render' in the maya help for more info.

Maya Command Line Options

  • A typical line will look like the following.

render -s 1 -e 100 -b 5 -pad 4 -cam camera3 -im myImage -rd R:\starHub\output\sc1sh03 -proj R:\starhub myScene.ma

  • -s 1 : startframe
  • -e 100 : endframe
  • -b 5 : every 5th frame
  • -pad 4 : pad using 4 zeros, ie myImage0034.tif
  • -cam camera3 : camera to render
  • -im myImage : image name to use
  • -rd R:\starHub\output\sc1sh03 : output render directory
  • -proj R:\starHub : path to project. note that it's the top level of the project, not the scene folder
  • myScene.ma : the scene itself, don't forget the space between the project path and the scene name!

  • Now you know how to launch a render from command line, you are able to create a simple render job list. Create a batch file (in windows os, a simple text file with .bat as the extension) in which you type each line a render task command. By running this batch file, when one of the render tasks ends the next one is launched.

Rendering backwards

To render backwards from a command line render:
render -s 50 -e 1 -b -1 -cam... etc

Blur2d and colour

If you use 2d motion blur, but don't render on a black background, you'll get ugly black fringing. To fix, go to your motion blur settings in render globals, turn on smooth colour and set the smooth value to zero.

Glow not going through transparency surfaces

A glow which is behind a transparency surfaces will not be displayed by the maya post render glow effect (even though opacity is turned to 0, for glasses for instance). It is due to the surface normals. To have the glow to go through these surfaces, make sure no normals faces the glow source. Go to the attribute editor Render Stats section of your transparency surfaces shape uncheck Double Sided (you may need to check Opposite). For poly surfaces, Edit Polygons > Normals > Reverse should help you too.

-- NicolasdHaussy? - 15 May 2005

Wireframe render with full shading


Duncan says:

"On the toon line node turn off all edges except for creases and make the creaseAngle min/max zero.(hardEdges only off) Also make the crease line width very small, but not zero. This will create triangle tubes along all edges after convert to poly."

I then assigned a blinn material to the resultant toon mesh, lit it with a physical sun sky. When I tried a full car mesh at once it complaind that I'd exceeded my toon mesh poly limit, I guess if I went and did it per sub-mesh, it'd be ok.

Wireframe render with backface culling

Probably the easiest way is this technique by Janne Ojala. It involves playblasting a wireframe on shaded viewport.

  1. In 'window->settings/preferences->colors' set the background colour to black, and the inactive poly/nurbs/trims colours to white.
  2. Create a lambert shader, make it black, apply to your object
  3. In a viewport menu choose 'shading->shade options->wireframe on shaded'
  4. Choose 'display->heads up display' and turn off all options. Also go into the camera attribute editor, expand 'display options', and turn off all options there too.
  5. Playblast!

If you need supersampling, you can approximate the HW buffer multipass jitter. Playblast several times, offseting the camera filmback by small amounts each time, then average them together in a comp.

Alternatively, you can oversample by rendering in tiles. Takes a little more work, but looks better. The numbers below are for a PAL frame, they may not work for other formats.

  1. Set your overscan to 1, and your camera scale to 0.5
  2. Playblast 4 tiles with the following film offsets:

NW tile NE tile
-0.59, 0.472 0.59, 0.472
SW tile SE tile
-0.59, -0.472 0.59, -0.472

Stitch these together in a comp, then resize back to a regular PAL frame.

Other methods

http://www.keegan3d.com/tutorials/tutorial--renderWireframe.htm is polys/subd's only, but its a clever trick. Auto-uv your model, render your uv's to file, then map them back onto your shape. In the tutorial he's also mapped the uv's to transparency, but if you skip this step you get nice backface culled wireframes. This method allows you to use the software render too, so quality isn't an issue.

http://www.jozvex.com/tutorials/wireframe.html uses the HW buffer, and a shrunk copy of your object to do backface culling. This method gets you antialiased lines for free (via HW buffer multipass), but you can't easily scale down nurbs or subdivs correctly (each face needs to be scaled on its normal via edit polys->move component), nor is it easy to setup for complex scenes.

There's two plugins that do nice software rendered wireframes, but may need some fiddling to handle backface culling.

When surfaces don't render


  • Visibility of the transform of your mesh as well as the mesh itself (if this is keyframed off, even if your object appears in the views, when you render a frame it will not show up)
  • Primary visibility in its render attributes
  • That it's not on a templated or invisible display layer
  • That you don't have enable render layers turned on, and your mesh on a disabled layer
  • That your shader is properly assigned
  • That the surface is being illuminated by at least one light
  • That you don't have 'render active' turned on in render globals
  • Normals are facing the right way (turn on 'double sided' if you're not sure)
  • That nurbs are adequately tesselated
  • That 'opacity gain' is set correctly in the shader
  • That you've not turned on 'black hole matte' in the shader

There's probably more but these are the most common problems.... Tips by Steve Davy

Imgcvt for fun and profit

To change a sequence of rla's to tiffs, try this:
imgcvt -v -C lzw -n 148 198 1 inImage#.rla outImage#.tif
  • -v verbose - see what its doing
  • -C lzw - compression for tiffs
  • -n 148 198 1 -work on frames 148 to 198, doing every frame
  • inImage#.rla - the input sequence
  • outImage#.tif - the output sequence, imgcvt works out the format from the suffix

Extracting Z-depth with fcheck

When you enable z-depth in your render globals, it should be the only option turned on. If you render with with both colour and z-depth and try and extract it in fcheck, it will blend the colour channels with the z-depth channel, regardless of whatever flags you implement.

The better way is to render out a z-depth pass solo, then open it in fcheck using the command

fcheck -Z -n <start> <end> <step> image.####.iff

Hit z to display the z-depth, and save it out using the standard GUI controls.

Enhance Maya JPEG quality

Default JPEG compression parameter seems to be quite high (and the images dirty). Run this it in the command line in order to have better quality JPEG outputs from Maya putenv "AW_JPEG_Q_FACTOR" "100";

-- NicolasdHaussy? - 06 May 2005

Putting instanced objects to separate layers

It can be done! But don't use "Add Selected Objects". Instead:

  • Open 'Window -> Relationship Editors -> Display Layers'
  • Select the layer you want to add the instance to in the left pane
  • Select the transform node of the instance in the right pane. Done!

Don't put the shape into the layer, otherwise you'll end up with that behavior that produces dumbfoundedness.

Topic attachments
I Attachment Action Size Date Who Comment
jpgjpg hardwareHalf.jpg manage 11.0 K 03 Sep 2006 - 22:11 MattEstela  
jpgjpg melOverrideScreenShot.jpg manage 32.9 K 08 Jan 2008 - 08:16 MattEstela  
jpgjpg perFaceLayers.jpg manage 30.6 K 03 Sep 2006 - 22:11 MattEstela  
elsema perFaceRenderLayers.ma manage 58.6 K 03 Sep 2006 - 22:11 MattEstela  
elsemel showMelOverrideEditor.mel manage 5.3 K 08 Jan 2008 - 08:17 MattEstela  
jpgjpg softwareHalf.jpg manage 9.0 K 03 Sep 2006 - 22:11 MattEstela  
jpgjpg wire_mr.jpg manage 90.8 K 16 Feb 2013 - 01:46 MattEstela wireframe render with mentalray shading
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r8 < r7 < r6 < r5 < r4 | More topic actions
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback