Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PreRender MEL - resolution and aspect ratio problem

0 REPLIES 0
Reply
Message 1 of 1
register
549 Views, 0 Replies

PreRender MEL - resolution and aspect ratio problem

Hey all!

 

So I have a bunch renderlayers in my scene, and I wish to render them with different resolutions and aspect ratio - like A3 portrait and A3 landscape.

There is a problem with this, and I´ve seen posts about it on other sites, but no solution.

What happens is that if you save your scene with a "A3 portrait" render layer active, and you wish to batchrender it starting from another render layer then the one active when saved  ...maya will take the aspect ratio from the renderlayer that was active when you saved, and use it on the first renderlayer in the batchrender process.

 

This, of course, is a problem if the first renderlayer in the batchrender process has a different aspect ratio then the renderlayer active when saving the scene.

It will render the correct resolution width and height , but with the wrong aspect ratio.

 

Workarounds:

 

1) Always activate the masterLayer when saving the scene.
This is a really bad solution but it seems to work.

 

2) Pre Render MEL script:

 

You could run a preRender MEL script that do this for you. It automatically selects the masterLayer before starting to render your renderLayers.
But it seems its not enough to run this script that changes the renderLayer: 

 

editRenderLayerGlobals -currentRenderLayer defaultRenderLayer;

 

You also need to re-set the image resolution width and height, together with the aspect ratio.
So we need to add something like this after changing the layer:

 

$width = `getAttr defaultResolution.width`;
$height = `getAttr defaultResolution.height`;
$deviceAspect = (float($width)/float($height));
setAttr defaultResolution.deviceAspectRatio $deviceAspect;

 

In theory this should work but it doesnt.
The problem is that Maya answers us with the resolutions from the renderLayer active when we opened the scene, even though we have changed the renderLayer to be the masterLayer before asking for the information.

 

This is what I have not been able to solve. How do I get the correct resolution information from the masterLayer?

 

There is a dirty workaround though... you could hardcode the resolution of the masterLayer into the script like this:

 

This is the complete script I use right now for command line rendering:

 

global proc vrayPreRender()
{
editRenderLayerGlobals -currentRenderLayer defaultRenderLayer;
setAttr defaultResolution.width 4961;
setAttr defaultResolution.height 3508;
$width = `getAttr defaultResolution.width`;
$height = `getAttr defaultResolution.height`;
$deviceAspect = (float($width)/float($height));
setAttr defaultResolution.deviceAspectRatio $deviceAspect;
}

 

This actually works (yay) , but I do not like it.
I want to get rid of the hardcoded resolution input.

 

Any ideas?

 

Thanks!

 

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums