Friday, 13 October 2017

Maya swatch headaches be-gone!

This was something that frustrated me this afternoon, so much that I thought I'd slap this very short and concise blog entry for anybody interested...

I loaded up a rather complex project to test that had been set up to use VRay materials, and had been choking up and causing havoc on the render-farm here. 

What I didn't know when I loaded this (given I've primarily been using Renderman) was that VRay was set to render all material swatches when I opened up the Hypershade - and when I say render, it cranked all 8 cores of my CPU to 100% and consumed around 3-4 Gigabytes of memory as it went.

A few minutes later once that was out of the way, Maya returned to normal and I thought I was fine...  Until I hit the swatches on file nodes!  While they shouldn't have done anything, they also started to choke Maya again.  Why - I'm not sure (hey, its Maya - if you've used it for a while, you learn not to be surprised by anything lol!) but I figured I'd had enough and quickly bashed out this python script to take care of setting everything OFF for the next scene I loaded (and needed to use Hypershade with)

The first part of this deals with VRay materials in particular.  I'd recommend if you have a very complex scene with LOTS of materials, you run this before opening the Hypershade (ie. why I wrote it).

# Optimise scene (VRay) to stop hogging CPU on workstation
import maya.cmds as cmds

# Disable all Swatches for materials (eats CPU and RAM!)
vrayMtls ='VRayMtl')
for mtl in vrayMtls:
    print "VRay Material : ",mtl
    attribName = mtl + '.swatchAutoUpdate'
    attribName = mtl + '.swatchAlwaysRender'
    attribName = mtl + '.swatchMaxRes'

The second part here deals with the preview thumbnail generation.  I decided that I wanted to keep the thumbnail generation on, but instead I forced it to low quality so it would be a little quicker to process.

# Lower the Preview thumb quality for images
imgFile ='file')
for img in imgFile:
    print "File node : ",img
    attribName = img + '.uvTileProxyQuality'

So there you have it.  This is just one of many issues I've run over - and while frustrating, they make for great excuse to play with a few scripting projects.


Post a Comment